Version 3.3.1.2

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 .

Drawers require a PropertyTree context, and are instantiated automatically by the .

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

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 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.
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