Version 3.3.0.1

OdinMenuEditorWindow class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public abstract class OdinMenuEditorWindow : OdinEditorWindow, ISerializationCallbackReceiver
Draws an editor window with a menu tree.
Inheritance
Implements
  • UnityEngine.ISerializationCallbackReceiver
Example
public class OdinMenuEditorWindowExample : OdinMenuEditorWindow
{
    [SerializeField, HideLabel]
    private SomeData someData = new SomeData();

    protected override OdinMenuTree BuildMenuTree()
    {
        OdinMenuTree tree = new OdinMenuTree(supportsMultiSelect: true)
        {
            { "Home",                           this,                           EditorIcons.House       }, // draws the someDataField in this case.
            { "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("More Odin Settings", SirenixAssetPaths.OdinEditorConfigsPath, typeof(ScriptableObject), true)
            .AddThumbnailIcons();

        tree.AddAssetAtPath("Odin Getting Started", SirenixAssetPaths.SirenixPluginPath + "Getting Started With Odin.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"));

        // As you can see, Odin provides a few ways to quickly add editors / objects to your menu tree.
        // The API also gives you full control over the selection, etc..
        // Make sure to check out the API Documentation for OdinMenuEditorWindow, OdinMenuTree and OdinMenuItem for more information on what you can do!

        return tree;
    }
}

Constructors

OdinMenuEditorWindow()
protected OdinMenuEditorWindow()

Fields

MenuBackgroundColor
protected Color MenuBackgroundColor

Properties

CustomSearchFunction
Gets or sets the custom search function.
public Func<OdinMenuItem, bool> CustomSearchFunction { get; set; }
DrawMenuSearchBar
Gets or sets a value indicating whether to draw the menu search bar.
public bool DrawMenuSearchBar { get; set; }
MenuTree
Gets the menu tree.
public OdinMenuTree MenuTree { get; }
MenuWidth
Gets or sets the width of the menu.
public virtual float MenuWidth { get; set; }
ResizableMenuWidth
Gets a value indicating whether the menu is resizable.
public virtual bool ResizableMenuWidth { get; set; }

Methods

BuildMenuTree()
Builds the menu tree.
protected abstract OdinMenuTree BuildMenuTree()
Returns
OdinMenuTree

DrawMenu()
The method that draws the menu.
protected virtual void DrawMenu()
ForceMenuTreeRebuild()
Forces the menu tree rebuild.
public void ForceMenuTreeRebuild()
GetTargets()
Draws the menu tree selection.
protected override IEnumerable<object> GetTargets()
Returns
System.Collections.Generic.IEnumerable<System.Object>

OnDestroy()
Called when the window is destroyed. Remember to call base.OnDestroy();
protected override void OnDestroy()
OnImGUI()
Draws the Odin Editor Window.
protected override void OnImGUI()
TrySelectMenuItemWithObject(Object)
Tries to select the menu item with the specified object.
public void TrySelectMenuItemWithObject(object obj)
Parameters
System.Object obj