Skip to main content
Tweeted twitter.com/StackGameDev/status/1341171659152240646
added 3 characters in body
Source Link
ejbytes
  • 131
  • 6
 //.... Gameobject tile; int count = 1;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++; } 

enter image description here enter image description here

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. UnixUnity, 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. UnixUnity 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?

 //.... Gameobject tile; int count = 1; 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++; } 

enter image description here enter image description here

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. Unix, 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. Unix 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?

 //.... 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++; } 

enter image description here enter image description here

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?

Bumped by Community user
added 415 characters in body; edited title
Source Link
ejbytes
  • 131
  • 6

Change Text - Inside A button, inside a Canvas, inside a GameObject: Access all the texts inside of hierchy?

 //.... Gameobject tile; int count = 1; 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++; } 

enter image description here enter image description here

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. Unix, 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. Unix 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?

Change Text - Inside A button, inside a Canvas, inside a GameObject

 //.... Gameobject tile; int count = 1; 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++; } 

enter image description here enter image description here

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. Unix, 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. Unix 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.

Change Text - Inside A button, inside a Canvas, inside a GameObject: Access all the texts inside of hierchy?

 //.... Gameobject tile; int count = 1; 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++; } 

enter image description here enter image description here

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. Unix, 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. Unix 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?

Source Link
ejbytes
  • 131
  • 6

Change Text - Inside A button, inside a Canvas, inside a GameObject

 //.... Gameobject tile; int count = 1; 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++; } 

enter image description here enter image description here

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. Unix, 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. Unix 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.