- Home /
Question by
ventiv · Nov 21, 2014 at 12:07 AM ·
javascriptguierrorguitext
How do I change the text of a gui image text
I'm trying to change the GUI's Text but the script gives me this error
and heres my script
#pragma strict
static var currentScore : int = 0;
var GUI2 : Transform;
function OnGUI ()
{
GUI2.text = ("Score: " +currentScore);
}
Comment
Answer by Jeff-Kesselman · Nov 21, 2014 at 12:08 AM
GUI2 is a trasform.
A transform does not have a guitext.
A game object may have a gui text.
try GUI2.gameObject.guitext.text
You can answer questions like this by yourself with a look at the API docs.
See
http://docs.unity3d.com/ScriptReference/Transform.html
and
Your answer
Follow this Question
Related Questions
JavaScript OnGUI GuiSkins aren't working, multiple scripts 1 Answer
What's wrong with eval()? 1 Answer
How to Get a Login Function to Work Locally? 1 Answer
Create GUIText from Javascript 3 Answers