//.... Gameobject tile; int count = 1f; float posX = 0; float posY = 0; ....// GameObject blueTile = (GameObject)Instantiate(Resources.Load("block_blue")); tile = (GameObject)Instantiate(blueTile, transform); for loop { ... ... tile.GetComponent().GetComponentInChildren().text = count.ToString(); tile.transform.position = new Vector2((float)posX, (float)posY); count++; }
As you can see by the image. My line of thinking goes like this; I used to create Flash/AS3 Applications and Games. I have used a number of API's and they usually have a lot in common. Unity, however, is very different and I may have not grasped the key concepts.
I want to access my PreFab, named in Assets/Resources (the root path)
"block_blue"
All I wan to do is set up a row and columns of a box with a number inside of it.
Before you go and ask, why the complicated mix of Objects? Well, Adobe had MovieClip and use of layers and also use of a timeline. Unity doesn't seem to have this in setting up a Scene (the Stage in Flash).
So, I set up a block that looks like this (right of main image 66): It's a Canvas, to hold a Button, the button has a text. To move the Canvas, I put the Canvas inside a GameObject. This, to me, is like a MovieClip in Flash API.
**GameObject > ButtonLight, Button > TextBlack, Text**
I need to access TextBlack and also Text. Pretty easy right? I've been at this for 4 days, many many hours.
EDIT: It seems that it is working, somewhat.
Looking at the reference photo and the Hierarchy reference, it looks like the blackText behind the blueText is changing as expected. But I cannot access the top BlueText. The Blue Text is also a child of type Text, but it's a second (layer?) copy of the text inside of the Button. So, it's getting the first Child Text, but how to access the second Text?