Namespace: | Sirenix.OdinInspector.Editor |
Assembly: | Sirenix.OdinInspector.Editor |
public class OdinMenuTree : IEnumerable
OdinMenuTree tree = new OdinMenuTree(supportsMultiSelect: true)
{
{ "Home", this, EditorIcons.House },
{ "Odin Settings", null, SdfIconType.GearFill },
{ "Odin Settings/Color Palettes", ColorPaletteManager.Instance, EditorIcons.EyeDropper },
{ "Odin Settings/AOT Generation", AOTGenerationConfig.Instance, EditorIcons.SmartPhone },
{ "Camera current", Camera.current },
{ "Some Class", this.someData }
};
tree.AddAllAssetsAtPath("Some Menu Item", "Some Asset Path", typeof(ScriptableObject), true)
.AddThumbnailIcons();
tree.AddAssetAtPath("Some Second Menu Item", "SomeAssetPath/SomeAssetFile.asset");
var customMenuItem = new OdinMenuItem(tree, "Menu Style", tree.DefaultMenuStyle);
tree.MenuItems.Insert(2, customMenuItem);
tree.Add("Menu/Items/Are/Created/As/Needed", new GUIContent());
tree.Add("Menu/Items/Are/Created", new GUIContent("And can be overridden"));
OdinMenuTrees are typically used with OdinMenuEditorWindows but is made to work perfectly fine on its own for other use cases.
OdinMenuItems can be inherited and and customized to fit your needs.
// Draw stuff
someTree.DrawMenuTree();
// Draw stuff
someTree.HandleKeybaordMenuNavigation();
public OdinMenuTree()
public OdinMenuTree(bool supportsMultiSelect)
System.Boolean | supportsMultiSelect | if set to |
public OdinMenuTree(bool supportsMultiSelect, OdinMenuStyle defaultMenuStyle)
System.Boolean | supportsMultiSelect | if set to |
OdinMenuStyle | defaultMenuStyle | The default menu item style. |
public OdinMenuTree(bool supportsMultiSelect, OdinMenuTreeDrawingConfig config)
System.Boolean | supportsMultiSelect | |
OdinMenuTreeDrawingConfig | config |
public static OdinMenuTree ActiveMenuTree
public List<OdinMenuItem> FlatMenuTree
public OdinMenuTreeDrawingConfig Config { get; set; }
public OdinMenuStyle DefaultMenuStyle { get; set; }
public bool DrawInSearchMode { get; }
public List<OdinMenuItem> MenuItems { get; }
public OdinMenuItem RootMenuItem { get; }
public OdinMenuTreeSelection Selection { get; }
public void Add(string path, object instance)
System.String | path | |
System.Object | instance |
public void Add(string path, object instance, SdfIconType icon)
System.String | path | |
System.Object | instance | |
SdfIconType | icon |
public void Add(string path, object instance, EditorIcon icon)
System.String | path | |
System.Object | instance | |
EditorIcon | icon |
public void Add(string path, object instance, Sprite sprite)
System.String | path | |
System.Object | instance | |
UnityEngine.Sprite | sprite |
public void Add(string path, object instance, Texture icon)
System.String | path | |
System.Object | instance | |
UnityEngine.Texture | icon |
public IEnumerable<OdinMenuItem> AddRange<T>(IEnumerable<T> collection, Func<T, string> getPath)
System.Collections.Generic.IEnumerable<T> | collection | |
System.Func<T, System.String> | getPath |
System.Collections.Generic.IEnumerable<OdinMenuItem> |
T |
public IEnumerable<OdinMenuItem> AddRange<T>(IEnumerable<T> collection, Func<T, string> getPath, Func<T, Texture> getIcon)
System.Collections.Generic.IEnumerable<T> | collection | |
System.Func<T, System.String> | getPath | |
System.Func<T, UnityEngine.Texture> | getIcon |
System.Collections.Generic.IEnumerable<OdinMenuItem> |
T |
public void DrawMenuTree()
public void DrawSearchToolbar(GUIStyle toolbarStyle = null)
UnityEngine.GUIStyle | toolbarStyle |
public void EnumerateTree(Action<OdinMenuItem> action)
System.Action<OdinMenuItem> | action |
public IEnumerable<OdinMenuItem> EnumerateTree(bool includeRootNode = false)
System.Boolean | includeRootNode | if set to |
System.Collections.Generic.IEnumerable<OdinMenuItem> |
public IEnumerable<OdinMenuItem> EnumerateTree(Func<OdinMenuItem, bool> predicate, bool includeRootNode)
System.Func<OdinMenuItem, System.Boolean> | predicate | The predicate. |
System.Boolean | includeRootNode | if set to |
System.Collections.Generic.IEnumerable<OdinMenuItem> |
public void FocusSearchField()
public bool HandleKeyboardMenuNavigation()
System.Boolean | Returns true, if anything was changed via the keyboard. |
public void MarkDirty()
public void MarkLayoutChanged()
public void ScrollToMenuItem(OdinMenuItem menuItem, bool centerMenuItem = false)
OdinMenuItem | menuItem | |
System.Boolean | centerMenuItem |
public void UpdateMenuTree()