- Home /
How to change the text on an other object ?
Ok so it's basicly easy to change the text on a Gui. But i'm trying to change the text of a Gui when the script is applied to the main camera.
The reason i want to know how to do this, because i don't have to create scripts for each Gui.
So how can i access the Gui from a script attached to an other object ?
Appreciate any help. ~Wentzel
Answer by Luci85 · Jul 03, 2012 at 08:58 PM
Get a reference to the script where the GUI is written and use a variable as GUI text.
var guireference:NameofScript
guireference = camera.GetComponent(NameofScript);
guireference.GUIText = "blabla";
Answer by irrationalistic · Jul 03, 2012 at 08:58 PM
You can use GameObject.Find("object name here").GetComponent().text =
Or you could create properties in your script that are something like public GUIText MyTextObject and set it in the editor to be your gameobject.
Your answer
Follow this Question
Related Questions
Change Text of GUI Button from Script 2 Answers
Detect Text in GUI; Print 1 Answer
GUI Problem 2 Answers
Limit on GUI Components? 0 Answers
Setting Scroll View Width GUILayout 1 Answer