Create gaps/headers between variables in editor?

Hi,

I couldn’t find anything on this in the answers or forums. I have a script with a very long list of variables that will be accessed by other scripts. It gets really messy because in the editor/component/script inspector its just one huge wall of text.

Is it possible to create headers for groups of variables or blank spaces between variables within a script? For example:

blank space/header

var p1
var p2
var p3

blank space/header

var o1
var o2
var o3

blank space/header

var y1
var y2
var y3

and so on.

I don’t know if it’s possible, but what would happen if you created a dummy variable like? (complete hack mind you!)

var p1
var p2
var p3
var _________1
var o1
var o2
var o3
var _________2
var y1
var y2
var y3
var _________3
var x1
var x2
var x3

Yeah, I thought about that, but I don’t really want to create 40/50 unused variables - would it not impact on performance if I did?

I’d use an array, or a custom inspector:

http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html

Of course, if you don’t need to assign them in the inpsector, you could make them invisible by creating private vars or using @HideInInspector

Thanks, I think I’ll use an array as it seems less involved than creating a custom window. Is there a way to change the name: Element 0, etc. to a custom one? Otherwise I’ll make do with noting what elements represent the accessed data. Cheers.

Yes, create an array of a custom class. If the first public variable is a string, it will show that string rather than ‘element’.

Another thing is to create a JS file that only contains variable declarations. This creates a class with the same name as the JS file, so if the filename was MyClass.js, the class name would be MyClass. You can then declare a variable of that class type in another script:-

var settings: MyClass;

The variables in that class will be accessible from the editor but they will appear with a disclosure triangle as if they were in a “folder”. This is quite a useful way of grouping variables that logically belong together and showing/hiding them separately.