Exposing Enums in Custom Inspector

I’m writing a custom inspector, and I’m trying to display enums the way Unity does naturally (displaying them and of course, changing them). After playing around with it my self, I managed to display the element’s names into a popup list, but selecting the values of the enums via popup list doesn’t have any actual effect.

Here is what I have so far:

var battleState : SerializedProperty;
var bsIndex : int;
var bsOptions : String[];

var infliction : SerializedProperty;
var iIndex : int;
var iOptions : String[];

var behavior : SerializedProperty;
var bIndex : int;
var bOptions : String[];

function ShowStates()

        //battleState.Enum = EditorGUILayout.EnumPopup("Battle State:", battleState);
         bsOptions = battleState.enumNames;
         bsIndex = EditorGUILayout.Popup(bsIndex, bsOptions);

         bOptions = behavior.enumNames;
         bIndex = EditorGUILayout.Popup(bIndex, bOptions);

         iOptions = infliction.enumNames;
         iIndex = EditorGUILayout.Popup(iIndex, iOptions);

Silly me! I solved it. For anyone in the future, this is what I did:

I took my serialized enum, and set the “enumValueIndex” equal to the index int I declared in my editor script.


battleState.enumValueIndex = bsIndex;