Show Static Variables in the Inspector

Is there a way to have UnityScript static variables display in the inspector and be modifiable there, just as public variables are?

No, only monobehaviour instance variables show up not class variables that have nothing to do with the component on the object at all technically

Durnit.

Thanks for the quick answer, D-man.

Best I can figure is maybe you can make a wrapper object. Make an empty game object and attach a script that has something like this:

public static var MyStaticVariable : int;
public var MyStaticVariableForInspector : int;
private void Awake()
{
	MyStaticVariable = MyStaticVariableForInspector.
}

Untested code of course. It’s kind of a hack though.

1 Like

The way FizixMan outlines, is the only way I know to accomplish this. I have used it without any issues, outside of keeping track of variable names, I usually have a convention I always stick to.

var viewableInInspector:int;
static var _viewableInInspector:int;

Something like that…

This is a valid workaround, and I confirm it works as I use it.

public static bool staticBool
public bool referenceToStaticBool

void Update()
{
referenceToStaticBool = staticBool
}

Use singleton instead

You can set a public variable to the static variable :slight_smile: