Version 2.1.0.0

OdinDrawer class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public abstract class OdinDrawer

Base class for all Odin drawers. In order to create your own custom drawers you need to derive from one of the following drawers:

Remember to provide your custom drawer with an Sirenix.OdinInspector.Editor.OdinDrawerAttribute in order for it to be located by the Sirenix.OdinInspector.Editor.DrawerLocator.

Drawers require a PropertyTree context, and are instantiated automatically by the Sirenix.OdinInspector.Editor.DrawerLocator.

Odin supports the use of GUILayout and takes care of undo for you. It also takes care of multi-selection in many simple cases. Checkout the manual for more information.

Inheritance
  • System.Object
  • OdinDrawer
See Also

Constructors

OdinDrawer()
protected OdinDrawer()

Properties

AutoSetGUIEnabled
If true, not-editable properties will not have its GUI being disabled as otherwise would be the case. This is useful if you want some GUI to be enabled regardless of whether a property is read-only or not. This value is true when an AllowGUIEnabledForReadonlyAttribute is defined on the drawer class itself.
protected bool AutoSetGUIEnabled { get; }
Initialized
Gets a value indicating if the drawer has been initialized yet.
public bool Initialized { get; }
Property
Gets the property this drawer draws for.
public InspectorProperty Property { get; }
SkipWhenDrawing
If true then this drawer will be skipped in the draw chain. Otherwise the drawer will be called as normal in the draw chain.
public bool SkipWhenDrawing { get; set; }

Methods

CallNextDrawer(GUIContent)
Calls the next drawer in the draw chain.
protected bool CallNextDrawer(GUIContent label)
Parameters
UnityEngine.GUIContent label

The label to pass on to the next drawer.

Returns
System.Boolean

CanDrawProperty(InspectorProperty)
Gets a value indicating if the drawer can draw for the specified property. Override this to implement a custom property filter for your drawer.
public virtual bool CanDrawProperty(InspectorProperty property)
Parameters
InspectorProperty property

The property to test.

Returns
System.Boolean

true if the drawer can draw for the property. Otherwise false.

CanDrawTypeFilter(Type)

Override this method in order to define custom type constraints to specify whether or not a type should be drawn by the drawer.

Note that Odin's Sirenix.OdinInspector.Editor.DrawerLocator has full support for generic class constraints, so most often you can get away with not overriding CanDrawTypeFilter.

public virtual bool CanDrawTypeFilter(Type type)
Parameters
System.Type type

The type.

Returns
System.Boolean

Returns true by default, unless overridden.

DrawProperty(GUIContent)
Draws the property with a custom label. This method also disables the GUI if the property is read-only and AutoSetGUIEnabled is false.
public void DrawProperty(GUIContent label)
Parameters
UnityEngine.GUIContent label

The label. Null is allow if you wish no label should be drawn.

DrawPropertyLayout(GUIContent)
Draws the property with GUILayout support.
protected virtual void DrawPropertyLayout(GUIContent label)
Parameters
UnityEngine.GUIContent label

The label. This can be null, so make sure your drawer supports that.

Initialize()
Initializes the drawer instance. Override this to implement your own initialization logic.
protected virtual void Initialize()
Initialize(InspectorProperty)
Initializes the drawer instance.
public void Initialize(InspectorProperty property)
Parameters
InspectorProperty property

Extension Methods

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.