protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label) { // If this is not used on an enum, show an error if (property.propertyType == SerializedPropertyType.Enum) { // 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, rect); label = EditorGUI.BeginProperty(rect, label, property); rect = EditorGUI.PrefixLabel(rect, id, label); GUIContent buttonText = new GUIContent(property.enumDisplayNames[property.enumValueIndex]); if (DropdownButton(id, rect, buttonText)) { Action <int> onSelect = i => { property.enumValueIndex = i; property.serializedObject.ApplyModifiedProperties(); }; SearchablePopup.Show(rect, property.enumDisplayNames, property.enumValueIndex, onSelect); } } else { string message = $"{nameof(SearchableEnumAttribute)} supports only enum fields"; DrawDefaultPropertyAndHelpBox(rect, property, message, MessageType.Warning); } }