public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // If this is not used on an enum, show an error if (property.type != "Enum") { GUIStyle errorStyle = "CN EntryErrorIconSmall"; Rect r = new Rect(position); r.width = errorStyle.fixedWidth; position.xMin = r.xMax; GUI.Label(r, "", errorStyle); GUI.Label(position, TYPE_ERROR); return; } // By manually creating the control ID, we can keep the ID for the // label and button the same. This lets them be selected together // with the keyboard in the inspector, much like a normal popup. if (idHash == 0) { idHash = "SearchableEnumAttributeDrawer".GetHashCode(); } int id = GUIUtility.GetControlID(idHash, FocusType.Keyboard, position); label = EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, id, label); GUIContent buttonText = new GUIContent(property.enumDisplayNames[property.enumValueIndex]); if (DropdownButton(id, position, buttonText)) { SearchablePopup.Show(position, property.enumDisplayNames, property.enumValueIndex, OnSelect); void OnSelect(int i) { property.enumValueIndex = i; property.serializedObject.ApplyModifiedProperties(); } } EditorGUI.EndProperty(); }