Namespace: | Sirenix.OdinInspector.Editor |
Assembly: | Sirenix.OdinInspector.Editor |
public sealed class InspectorTypeDrawingConfig
Contains configuration data for which types Odin should draw in the inspector.
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).
public InspectorTypeDrawingConfig()
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
public void ClearEditorEntryForDrawnType(Type drawnType)
System.Type | drawnType | The drawn type to clear the editor for. |
System.ArgumentNullException | drawnType is null |
public List<Type> GetAllDrawnTypesWithEntries()
System.Collections.Generic.List<System.Type> |
public static Type GetDefaultEditorType(Type drawnType)
System.Type | drawnType | The drawn type to get the default editor for. |
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. |
System.ArgumentNullException | drawnType is null |
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)
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. |
System.Type |
System.ArgumentNullException | editorType |
public Type GetEditorType(Type drawnType)
System.Type | drawnType | The drawn type to get an editor type for. |
System.Type | The editor that would draw the given type. |
System.ArgumentNullException | drawnType is null |
public bool HasEntryForType(Type drawnType)
System.Type | drawnType | The drawn type to check. |
System.Boolean |
System.ArgumentNullException | drawnType is null |
public void ResetToDefault()
public void SetEditorType(Type drawnType, Type editorType)
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. |
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). |
public static bool UnityInspectorEditorIsValidBase(Type editorType)
System.Type | editorType | Type of the editor to check. |
System.Boolean | True if the editor is valid, otherwise false |
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)
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. |
System.Boolean | True if the editor is valid, otherwise false |
System.ArgumentNullException | editorType |
public void UpdateCaches()