Version 3.3.1.2

InspectorTypeDrawingConfig class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public sealed class InspectorTypeDrawingConfig

Contains configuration data for which types Odin should draw in the inspector.

Inheritance
  • System.Object
  • InspectorTypeDrawingConfig
Remarks

Note that this class supports assigning arbitrary editor types to inspect any Unity object type. The Editor Types GUI in preferences simply does not, as of now, support assigning editors of any other type than OdinEditor. However, the API is open to further customization.

When an editor is generated for a type, a new editor type is added to the GeneratedOdinEditors assembly, which is derived from the assigned editor type - in most cases, OdinEditor.

You can check if an editor is compatible using UnityInspectorEditorIsValidBase(Type, Type).

Constructors

InspectorTypeDrawingConfig()
public InspectorTypeDrawingConfig()

Fields

TypeBinder

The type binder that the InspectorTypeDrawingConfig uses to bind types to names, and names to types.

This is usually an instance of DefaultSerializationBinder.

public static readonly TwoWaySerializationBinder TypeBinder

Methods

ClearEditorEntryForDrawnType(Type)
Clears the editor type entry for the given drawer, so it will be set to Unity's default.
public void ClearEditorEntryForDrawnType(Type drawnType)
Parameters
System.Type drawnType

The drawn type to clear the editor for.

Exceptions
System.ArgumentNullException

drawnType is null

GetAllDrawnTypesWithEntries()
Gets a list of all drawn types that have entries in the drawing config.
public List<Type> GetAllDrawnTypesWithEntries()
Returns
System.Collections.Generic.List<System.Type>

GetDefaultEditorType(Type)
Gets the default editor that this type would have, if no custom editor was set for this type in particular. This is calculated using the value of DefaultEditorBehaviour.
public static Type GetDefaultEditorType(Type drawnType)
Parameters
System.Type drawnType

The drawn type to get the default editor for.

Returns
System.Type

The editor that would draw this type by default, or null, if there is no default Odin-defined editor for the drawn type.

Exceptions
System.ArgumentNullException

drawnType is null

GetEditorDrawnType(Type, out Boolean)

Gets the type that an editor draws, by extracting it from the editor's UnityEditor.CustomEditor attribute, if it is declared.

This method returns null for abstract editor types, as those can never draw anything.

public static Type GetEditorDrawnType(Type editorType, out bool editorForChildClasses)
Parameters
System.Type editorType

Type of the editor.

System.Boolean editorForChildClasses

Whether the editor in question is also an editor for types derived from the given type.

Returns
System.Type

Exceptions
System.ArgumentNullException

editorType

GetEditorType(Type)
Gets which editor type would draw the given type. If the type has not been assigned a custom editor type in the config, the default editor type is returned using GetDefaultEditorType(Type).
public Type GetEditorType(Type drawnType)
Parameters
System.Type drawnType

The drawn type to get an editor type for.

Returns
System.Type

The editor that would draw the given type.

Exceptions
System.ArgumentNullException

drawnType is null

HasEntryForType(Type)
Determines whether an editor value has been assigned for a given drawn type.
public bool HasEntryForType(Type drawnType)
Parameters
System.Type drawnType

The drawn type to check.

Returns
System.Boolean

Exceptions
System.ArgumentNullException

drawnType is null

ResetToDefault()
Resets the drawing configuration to the default values.
public void ResetToDefault()
SetEditorType(Type, Type)
Assigns a given editor to draw a given type.
public void SetEditorType(Type drawnType, Type editorType)
Parameters
System.Type drawnType

The drawn type to assign an editor type for.

System.Type editorType

The editor type to assign. When generating editors, a type derived from this editor will be created and set to draw the given drawn type.

Exceptions
System.ArgumentNullException

drawnType

System.ArgumentException

The type " + editorType.GetNiceName() + " is not a valid base editor for type " + drawnType.GetNiceName() + ". Check criteria using UnityInspectorEditorIsValidBase(Type, Type).

UnityInspectorEditorIsValidBase(Type)
Checks whether the given editor can be assigned to draw any type using the InspectorTypeDrawingConfig class.
public static bool UnityInspectorEditorIsValidBase(Type editorType)
Parameters
System.Type editorType

Type of the editor to check.

Returns
System.Boolean

True if the editor is valid, otherwise false

UnityInspectorEditorIsValidBase(Type, Type)

Checks whether the given editor can be assigned to draw a given type using the InspectorTypeDrawingConfig class.

This method checks the UnityEditor.CustomEditor attribute on the type for whether the given type is compatible.

public static bool UnityInspectorEditorIsValidBase(Type editorType, Type drawnType)
Parameters
System.Type editorType

Type of the editor to check.

System.Type drawnType

Type of the drawn value to check. If this parameter is null, the drawn type is not checked for compatibility with the editor type; only the editor type itself is checked for validity.

Returns
System.Boolean

True if the editor is valid, otherwise false

Exceptions
System.ArgumentNullException

editorType

UpdateCaches()
Forces the config's internal drawer type to value type lookup cache to rebuild itself.
public void UpdateCaches()