How does one inspect static vars?

Debug mode in the inspector only reveals private vars. I understand that static vars are global, but there has to be an easy way to see, say, a static array, that doesn't involve scripting a gui readout.

While not the most effective solution, I did find a workaround. If you know the class of your object you can create a public var of that class (class MUST be defined) and set it equal to your static var each frame. The limitation of this approach is that data types such as Arrays (things that aren't serializable because they may contain items of different classes) can't be viewed in the inspector. : (

You can even take it one step further: You can keep track of the last value in your local property that is shown in the inspector. Then, in each update, check if that local value has changed, and if it has, set the static variable. In other words: You keep two local variables, the one exposed in the inspector and another one that could even be private. In Awake(), you'd set both the private and static variable (pull the value from the public variable). In each Update(), if the private variable is different from the public one, set both the static variable and the private one to the value of the public one (that obviously just has changed).

That way, you can not only inspect the static variable - you can also change it from the inspector.

If you're using a lot of static variables, you might consider creating one "static variables manager object" that controls all of them ("one ring, um, class to rule them all" ;-) ).

/shameless plug/ I’ve used .NET reflection to create a new editor window that can inspect any field or property of any Unity or .NET object, including public, private and static variables. There’s a screenshot of an earlier version of the tool here, and a list of current and planned features on this Trello board. I will release this tool in the Asset Store in the not too distant future. I’m looking for a few more beta testers if you’re interested – you’ll get a free copy and my eternal gratitude! Drop me a note if you’re interested in beta testing, or just want to talk about .NET reflection techniques. You can reach me at yoyo (at) zeroandone (dot) ca.