Use [`Singleton`][1]s!
====
They're [**much** better than using static][2].
Grab the singleton script above and simply use it as such:
public class MyClass : MonoBehaviour {
void Awake () {
Debug.Log(Manager.Instance.myGlobalVar);
}
}
**Manager.cs**
public class Manager : Singleton {
public string myGlobalVar = "whatever";
}
[1]: http://wiki.unity3d.com/index.php/Singleton
[2]: http://forum.unity3d.com/threads/197169-Singleton-vs-Static
↧