- Home /
Question by
CallMeFriend · Aug 10, 2014 at 09:27 PM ·
guiguitext
Change guiText to TextMesh?
Hey guys
I have this code: guiText.text = transform.parent.guiText.text;
That basically change the gui text to the parent text.
Anyone knows how can i change in the code from guiText to TextMesh?
Thanks!
Comment
Best Answer
Answer by robertbu · Aug 10, 2014 at 09:57 PM
C#
GetComponent<TextMesh>().text = transform.parent.GetComponent<TextMesh>().text;
Javascript:
GetComponent(TextMesh).text = transform.parent.GetComponent(TextMesh).text;
If you are going to be doing this every frame, it might pay to save the reference acquired by GetComponent() rather than call GetComponent() twice every frame.