Namespace: | Sirenix.OdinInspector.Editor |
Assembly: | Sirenix.OdinInspector.Editor |
public class EnumSelector<T> : OdinSelector<T>, ISelectionChangeListener
KeyCode someEnumValue;
[OnInspectorGUI]
void OnInspectorGUI()
{
// Use the selector manually. See the documentation for OdinSelector for more information.
if (GUILayout.Button("Open Enum Selector"))
{
EnumSelector<KeyCode> selector = new EnumSelector<KeyCode>();
selector.SetSelection(this.someEnumValue);
selector.SelectionConfirmed += selection => this.someEnumValue = selection.FirstOrDefault();
selector.ShowInPopup(); // Returns the Odin Editor Window instance, in case you want to mess around with that as well.
}
// Draw an enum dropdown field which uses the EnumSelector popup:
this.someEnumValue = EnumSelector<KeyCode>.DrawEnumField(new GUIContent("My Label"), this.someEnumValue);
}
// All Odin Selectors can be rendered anywhere with Odin. This includes the EnumSelector.
EnumSelector<KeyCode> inlineSelector;
[ShowInInspector]
EnumSelector<KeyCode> InlineSelector
{
get { return this.inlineSelector ?? (this.inlineSelector = new EnumSelector<KeyCode>()); }
set { }
}
public EnumSelector()
public static bool DrawSearchToolbar
public bool IsFlagEnum { get; }
public override string Title { get; }
protected override void BuildSelectionTree(OdinMenuTree tree)
OdinMenuTree | tree |
protected override float DefaultWindowWidth()
System.Single |
public static T DrawEnumField(GUIContent label, T value, GUIStyle style = null)
UnityEngine.GUIContent | label | |
T | value | |
UnityEngine.GUIStyle | style |
T |
public static T DrawEnumField(GUIContent label, GUIContent contentLabel, T value, GUIStyle style = null, SdfIconType valueIcon = SdfIconType.None)
UnityEngine.GUIContent | label | |
UnityEngine.GUIContent | contentLabel | |
T | value | |
UnityEngine.GUIStyle | style | |
SdfIconType | valueIcon |
T |
public static T DrawEnumField(Rect rect, GUIContent label, T value, GUIStyle style = null)
UnityEngine.Rect | rect | |
UnityEngine.GUIContent | label | |
T | value | |
UnityEngine.GUIStyle | style |
T |
public static T DrawEnumField(Rect rect, GUIContent label, GUIContent contentLabel, T value, GUIStyle style = null, SdfIconType valueIcon = SdfIconType.None)
UnityEngine.Rect | rect | |
UnityEngine.GUIContent | label | |
UnityEngine.GUIContent | contentLabel | |
T | value | |
UnityEngine.GUIStyle | style | |
SdfIconType | valueIcon |
T |
public override IEnumerable<T> GetCurrentSelection()
System.Collections.Generic.IEnumerable<T> |
public override void SetSelection(T selected)
T | selected |