|
Hi - i'm instantiating a prefab at runtime, and trying to set the gui text of a nested gameobject, but my syntax isn't working. This is my code: how do I do this properly?
(comments are locked)
|
|
Seems you mean: thanks - that worked. Revised code as follows: var scoreBoard = Instantiate(scoreBoard, Vector3 (0, 0, 0), Quaternion.identity); var playerScore = scoreBoard.transform.Find("YourScore"); playerScore.guiText.text = scoreTextRef.text;
Jul 29 '11 at 03:07 PM
heaversm
While this is correct, it's bad form to use the same name for your new local variable as the name of the member variable, so either name the member to eg. scoreBoardPrefab or the new local variable to eg. scoreBoardInstance.
Jul 29 '11 at 05:27 PM
Waz
Gotcha, thanks.
Jul 29 '11 at 06:00 PM
heaversm
(comments are locked)
|

It is a bit odd that the variable you are Instantiating is the same name as the one you're then assigning to. I presume there is a class member called scoreBoard that you are dragging a prefab to.