I really like how Enum’s are displayed in the inspector: ie, you can click the field, see a drop down of all possible options, and select one.
I’m wondering if its possible to display a list in this fashion?
I really like how Enum’s are displayed in the inspector: ie, you can click the field, see a drop down of all possible options, and select one.
I’m wondering if its possible to display a list in this fashion?
using UnityEditor;
using System.Collections.Generic;
[CustomEditor(typeof(StatList))]
public class StatListEditor: Editor
{
public List<string> statList = new List<string>()
{
"hp", "mp", "str", "lck", "dmg"
};
public int selectedIndex = 0;
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PrefixLabel("Attributes");
selectedIndex = EditorGUILayout.Popup(selectedIndex, statList.ToArray());
serializedObject.ApplyModifiedProperties();
}
}
What do I do if the list for which I want to create a dropdown menu (which will be visible in the “StatList” script) is found in the “StatList” script itself and not in the “StatListEditor” script editor?