- Home /
Question by
EggQuiz857 · Apr 12, 2015 at 10:57 PM ·
scripting problemguitext
Displaying my variable on a gui text
Ok I have this script.
#pragma strict
var Desplay : GameObject; //gameobject is the display text box
var Money : int;
function Start () {
Desplay. //cant figure out the rest of this
}
function Update () {
}
So what it has is the object as a variable and it accesses it by using display. witch is the text box. what I need to do is have the Text(Script)'s text component to be equal to the var money.
I tried to do it like Desplay.getComponent.guiText.text == Money. it didn't work. so can someone help
Comment
Did you try OnGUI function? If not I think you should give it a try. GUI Basics
Are you using the Unity 4.6 UI text? If you are, add
import UnityEngine.UI;
and use this to set the text
Desplay.GetComponent(Text).text = $$anonymous$$oney.ToString();