Dynamic GUI Text

Hello All! First off, I would like to say hello to the community, this is my first post here.

I’m currently creating my frist Unity Game and to be breif, i’m a novice! Ok, So Im currently setting up a GUI for my game. I have created a GUI Text Layer, which I want to make dynamic, so that I can set a global variable and ‘grab’ the string, then change the text value of the GUI text layer accordingly.

I apologise for my ignorance, for I am a complete beginner, if someone could point me in the direction of some documentation which could help me, or just breifly explain how to deal with the problem, that would be great. Any help is much appreciated.

-Jon

Assuming you are using GUIText, is it actually quite simple. Create a script - Lets call it staticText - and add the following code to it. Make sure and drag the script to the GUIText object.

static var text : String;

function Update() {
   guiText.text = text;
}

That is literally all there is to it. To change the text from any other script just add a line like this:

staticText.text = "Unity is totally awesome";

Ah! Works great, Thanks alot.