- Home /
Question by
DNP · Jul 24, 2012 at 01:47 AM ·
javascriptguitext
GUIText Help
How can i change a GUIText's text through a script? Javascript to be precise.
Comment
Best Answer
Answer by aldonaletto · Jul 24, 2012 at 01:52 AM
Just assign the new text to the guiText.text property - this works in the GUIText object; if you want to control the GUIText from another script, set a reference to it in the Inspector:
// this is the control script:
var gText: GUIText; // drag the guiText from Hierarchy to here
// Example: show Time.time in seconds with 1 decimal digit
function Update(){
gText.text = Time.time.ToString("F1");
}
Your answer
Follow this Question
Related Questions
Create GUIText from Javascript 3 Answers
How to draw GUI Text from code 1 Answer
What Am I Doing Wrong? Variable Names 3 Answers