Access variable from multiple scripts

How to access a variable from multiple scripts? How to make the scripts relative? For example, I have a GuiText and I want to make only one GuiText which will change the text eventually as the selection changes. Any ideas? Thanks. :slight_smile:

You could also just make an ugly STATIC version of your variables.

Like:

public static string myGlobalValue = "Hello World";

I usually have a “Global.cs” scriptfile for such ugly variables, because they are faster to access. Eg. if I have a serveraddress. I just keep a:

public static string urlServer = "http://www.someserver.com/";

Then when I need this value in subscripts that access assets or stores a hiscore, I can use that top-level variable in every call like this:

WWW w = new WWW( Global.urlServer + "/somefile.txt");

I dont know if thats too ugly, but it solves my problem perfectly.

RTM at : http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html