Static, but visible in inspector?

hey guys,

I'm trying to use a script, where I assign different GUITextures with the inspector.

Now I also want, that these GUITextures can me manipulated by other scripts. When I use static for that, I cant assign the textures to the variables.

What should I do about that?

If you have a manager class that have some public variables to assign some global useable references like GUISkin, prefabs, textures you can use the singleton pattern. You have only one instance of that class and this can store everything you like. A "normal" singleton would have a private constructor to prevent that more instances of that class are created. In Unity we won't do that to enable Unity to create our Component.

In C# a singleton can be implemented like this:

public class ObjectManager : MonoBehaviour
{
    // singleton
    private static ObjectManager m_Instance = null;
    public static ObjectManager Get()
    {
        if (m_Instance == null)
            m_Instance = (ObjectManager)FindObjectOfType(typeof(ObjectManager));
        return m_Instance;
    }
    // class 
    public GUISkin MySkin;
    public Transform PlayerPrefab;
    public Transform BulletPrefab;
}

This script have to be placed only once in the scene and you can assign your variables in the inspector.

In UnityScript(Javascript) it looks similar:

// singleton
private static var m_Instance : ObjectManager = null;
static function Get() : ObjectManager
{
    if (m_Instance == null)
        m_Instance = FindObjectOfType(ObjectManager);
    return m_Instance;
}
// class 
var MySkin : GUISkin;
var PlayerPrefab : Transform;
var BulletPrefab : Transform;

Now, in any script you can use the variables very easy:

// some examples
GUILayout.Label("text", ObjectManager.Get().MySkin.label);
Instantiate(ObjectManager.Get().PlayerPrefab);
Instantiate(ObjectManager.Get().BulletPrefab);
GUI.skin = ObjectManager.Get().MySkin;

You don't need variables to be static to be manipulated by other scripts, they just have to be public. And they have to be public to be assigned in the inspector, so you're all set. In fact you should generally not use static variables unless you specifically mean for only one instance of said variables to exist, since that's what static means. Static does NOT mean "global" in any way; people seem to get confused about that.