2using System.Collections.Generic;
12 public List<PlatformServer>
enumList =
new List<PlatformServer>();
25 [CustomPropertyDrawer(typeof(EndpointDisplayAttribute))]
26 public class EndpointDisplayDrawer : PropertyDrawer
29 int selectedIndex = -1;
31 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
33 EndpointDisplayAttribute displayAttribute = attribute as EndpointDisplayAttribute;
35 if (displayAttribute.enumDisplayList.Count > 0)
37 int newIndex = EditorGUI.Popup(position, property.name, selectedIndex, displayAttribute.enumDisplayList.ToArray());
40 newIndex =
property.enumValueIndex;
43 if (newIndex != selectedIndex)
45 selectedIndex = newIndex;
46 property.enumValueIndex = selectedIndex;
47 UnityEngine.Object dirtyObject =
property.serializedObject.targetObject;
49 if (dirtyObject !=
null)
51 Debug.Log(
"Selected Index: " + selectedIndex);
52 EditorUtility.SetDirty(dirtyObject);
59 EditorGUI.PropertyField(position, property, label);
EndpointDisplayAttribute()
List< string > enumDisplayList
List< PlatformServer > enumList