Version 3.3.1.2

OdinMenuItem class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public class OdinMenuItem
A menu item that represents one or more objects.
Inheritance
  • System.Object
  • OdinMenuItem

Constructors

OdinMenuItem(OdinMenuTree, String, Object)
Initializes a new instance of the OdinMenuItem class.
public OdinMenuItem(OdinMenuTree tree, string name, object value)
Parameters
OdinMenuTree tree

The Odin menu tree instance the menu item belongs to.

System.String name

The name of the menu item.

System.Object value

The instance the value item represents.

Fields

DefaultToggledState
The default toggled state
public bool DefaultToggledState
MenuItemIsBeingRendered
public bool MenuItemIsBeingRendered
OnDrawItem
Occurs right after the menu item is done drawing, and right before mouse input is handles so you can take control of that.
public Action<OdinMenuItem> OnDrawItem
OnRightClick
Occurs when the user has right-clicked the menu item.
public Action<OdinMenuItem> OnRightClick
SdfIcon
public SdfIconType SdfIcon
SdfIconColor
public Color? SdfIconColor

Properties

ChildMenuItems
Gets the child menu items.
public virtual List<OdinMenuItem> ChildMenuItems { get; }
FlatTreeIndex
Gets the index location of the menu item.
public int FlatTreeIndex { get; }
Icon
Gets or sets the icon that is used when the menu item is not selected.
public Texture Icon { get; set; }
IconGetter
Gets or sets the icon getter.
public Func<Texture> IconGetter { get; set; }
IconSelected
Gets or sets the icon that is used when the menu item is selected.
public Texture IconSelected { get; set; }
IsEnabled
Determines whether this instance is enabled.
public bool IsEnabled { get; set; }
IsSelectable
Determines whether this instance is selectable.
public bool IsSelectable { get; set; }
IsSelected
Gets a value indicating whether this instance is selected.
public bool IsSelected { get; }
LabelRect
Gets the drawn label rect.
public Rect LabelRect { get; }
MenuTree
Gets the menu tree instance.
public OdinMenuTree MenuTree { get; }
Name
Gets or sets the raw menu item name.
public string Name { get; set; }
NextSelectableMenuItem
Gets the next selectable visual menu item.
public OdinMenuItem NextSelectableMenuItem { get; }
NextVisualMenuItem
Gets the next visual menu item.
public OdinMenuItem NextVisualMenuItem { get; }
Parent
Gets the parent menu item.
public OdinMenuItem Parent { get; }
PrevSelectableMenuItem
Gets the previous selectable visual menu item.
public OdinMenuItem PrevSelectableMenuItem { get; }
PrevVisualMenuItem
Gets the previous visual menu item.
public OdinMenuItem PrevVisualMenuItem { get; }
Rect
Gets the drawn rect.
public Rect Rect { get; }
SearchString
Gets or sets the search string used when searching for menu items.
public string SearchString { get; set; }
SmartName
Gets a nice menu item name. If the raw name value is null or a dollar sign, then the name is retrieved from the object itself via ToString().
public virtual string SmartName { get; }
Style
Gets or sets the style. If null is specified, then the menu trees DefaultMenuStyle is used.
public OdinMenuStyle Style { get; set; }
Toggled
Gets or sets a value indicating whether this OdinMenuItem is toggled / expanded. This value tries it best to be persistent.
public virtual bool Toggled { get; set; }
Value
Gets or sets the value the menu item represents.
public object Value { get; set; }

Methods

Deselect()
Deselects this instance.
public bool Deselect()
Returns
System.Boolean

DrawMenuItem(Int32)
Draws the menu item with the specified indent level.
public virtual void DrawMenuItem(int indentLevel)
Parameters
System.Int32 indentLevel

DrawMenuItems(Int32)
Draws this menu item followed by all of its child menu items
public virtual void DrawMenuItems(int indentLevel)
Parameters
System.Int32 indentLevel

The indent level.

GetChildMenuItemsRecursive(Boolean)
Gets the child menu items recursive in a DFS.
public IEnumerable<OdinMenuItem> GetChildMenuItemsRecursive(bool includeSelf)
Parameters
System.Boolean includeSelf

Whether to include it self in the collection.

Returns
System.Collections.Generic.IEnumerable<OdinMenuItem>

GetFullPath()
Gets the full menu item path.
public string GetFullPath()
Returns
System.String

GetParentMenuItemsRecursive(Boolean, Boolean)
Gets the child menu items recursive in a DFS.
public IEnumerable<OdinMenuItem> GetParentMenuItemsRecursive(bool includeSelf, bool includeRoot = false)
Parameters
System.Boolean includeSelf

Whether to include it self in the collection.

System.Boolean includeRoot

Whether to include the root.

Returns
System.Collections.Generic.IEnumerable<OdinMenuItem>

HandleMouseEvents(Rect, Rect)
Handles the mouse events.
protected void HandleMouseEvents(Rect rect, Rect triangleRect)
Parameters
UnityEngine.Rect rect

The rect.

UnityEngine.Rect triangleRect

The triangle rect.

OnDrawMenuItem(Rect, Rect)
Override this to add custom GUI to the menu items. This is called right after the menu item is done drawing, and right before mouse input is handles so you can take control of that.
protected virtual void OnDrawMenuItem(Rect rect, Rect labelRect)
Parameters
UnityEngine.Rect rect

UnityEngine.Rect labelRect

Remove()
public void Remove()
Select(Boolean)
Selects the specified add to selection.
public void Select(bool addToSelection = false)
Parameters
System.Boolean addToSelection

Extension Methods