protected override void OnDrawProperty(string label) { var attr = GetAttr <IntSliderAttribute>(); int leftValue = attr.LeftValue; int rightValue = attr.RightValue; if (!string.IsNullOrEmpty(attr.LeftValueMemberName)) { leftValue = NativeDrawerUtility.GetMemberValue <int>(attr.LeftValueMemberName, DrawerProperty.Target); } if (!string.IsNullOrEmpty(attr.RightValueMemberName)) { rightValue = NativeDrawerUtility.GetMemberValue <int>(attr.RightValueMemberName, DrawerProperty.Target); } label = label ?? ""; int value = DrawerProperty.GetValue <int>(); EditorGUI.BeginChangeCheck(); { value = EditorGUILayout.IntSlider(label, value, leftValue, rightValue); } if (EditorGUI.EndChangeCheck()) { DrawerProperty.Value = value; } }
protected override void OnDrawProperty(string label) { var attr = GetAttr <StringPopupAttribute>(); string[] options = attr.Options; if (!string.IsNullOrEmpty(attr.MemberName)) { options = NativeDrawerUtility.GetMemberValue <string[]>(attr.MemberName, DrawerProperty.Target); } var value = DrawerProperty.GetValue <string>(); label = label ?? ""; if (attr.IsSearchable) { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel(label); Rect btnRect = GUILayoutUtility.GetRect(new GUIContent(value), "dropdownbutton"); if (EditorGUI.DropdownButton(btnRect, new GUIContent(value), FocusType.Keyboard)) { try { SearchablePopup.Show(btnRect, new Vector2(200, 400), Array.IndexOf(options, value), options, (selected) => { DrawerProperty.Value = options[selected]; }); } catch (ExitGUIException) { lastSearchableWindow = EditorWindow.focusedWindow; throw; } } } EditorGUILayout.EndHorizontal(); if (lastSearchableWindow && lastSearchableWindow != EditorWindow.mouseOverWindow) { if (Event.current.type == EventType.ScrollWheel) { Event.current.Use(); } } } else { EditorGUI.BeginChangeCheck(); { value = EGUILayout.DrawPopup <string>(label, options, options, value); } if (EditorGUI.EndChangeCheck()) { DrawerProperty.Value = value; } } }