Static variables explanation.

Hey.

I have a question. I’m working on a rpg game and I’m using static var to access varibles from other scripts. It works good exept for one thing. The static varibles doesn’t show up in the inspector window. Is this a bug or a feature in unity? And what other ways are there to access varibles from other scripts? I don’t understand this:

http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Thanks.
//Proximal-Pyro

Which part of it you do not understand? Please don’t say the whole thing.

public static variables are not shown in the inspector because static variables belong to the class itself, not the object/instance of the class.

Non-static variables in the other hand, belongs to the object/instance of the class. When a gameObject is attached with a script, it becomes the object/instance of the class of the script, and hence, the public non-static variables will then be exposed in the inspector.

Variables which are static are not related to the specific object and so do not show up in the inspector. Using Static may not be the best method (see GetComponent articles on Unity Gems) but if you do decide on that route - you can create a script that has normal variables which it puts into the statics on Awake - then you have a way of defining them in the inspector.