Custom editor not editing?

Hi all,

I’ve been trying to get a script of mine to only display some variables in the inspector if an enum is at a particular value. I see I have to use a Custom Editor to do this. I’ve been fiddling with one for a while now, but it doesn’t seem to work at all - I don’t think it’s registering what script it’s supposed to be editing?

Here’s the PanelCustomInspector.js in the Editor folder:


var types : panelTypes;
var directions : pathDirections;

class PanelCustomInspector extends Editor
	function OnInspectorGUI()
		EditorGUILayout.LabelField("This is" , "a test.");
		target.panelType = EditorGUILayout.EnumPopup(types);
		var workaround : panelTypes = target.panelType; //[necessary][1]
		if(workaround == panelTypes.Path)
			target.pathDirection = EditorGUILayout.EnumPopup(directions);

And here’s the PanelController.js in a different folder:

var panelType = panelTypes.Buildable;
var pathDirection = pathDirections.Right;

function OnDrawGizmos()
	//Draw a particular gizmo, depending on what direction the path is

The editor just shows the panelType and pathDirection variables of the PanelController.js script and the test label doesn’t show up. Any help would be appreciated!

Move the variables “types” and “directions” to Inside the class.

A JS files with anything but a single class declaration is magically wrapped into a class named by the file, so your code would be a class nested inside a class of the same name, or something weird like that.