ParagonBehaviourEditor

Custom Odin Inspector editor for all ParagonBehaviour subclasses. Manages the subsystem property (enable/disable), debug toggle, and ensures the subsystem field is drawn last in the Inspector via an Odin attribute processor.

Definition

Namespace: Paragon.Editor Assembly: Paragon.Editor.dll

[CustomEditor(typeof(ParagonBehaviour), true, isFallback = true)]
public class ParagonBehaviourEditor : ParagonEditor<ParagonBehaviour>

Inheritance: OdinEditorParagonEditorParagonEditor<ParagonBehaviour>ParagonBehaviourEditor

Remarks

This editor is registered as a fallback editor (isFallback = true) for ParagonBehaviour and all derived types (true for editorForChildClasses). This means it applies to every ParagonBehaviour in the project unless a more specific custom editor is defined.

Key responsibilities:

  1. Subsystem property management — On OnCreateGUI(), it resolves the subsystem InspectorProperty from Odin's property tree. The EnableSubsystem() / DisableSubsystem() methods create or null out the subsystem instance.

  2. Debug toggleSetDebugEnabled() sets the DebugEnabled flag and marks the target dirty.

  3. Property ordering — A nested AttributeProcessor adds [PropertyOrder(int.MaxValue)] to the subsystem field, ensuring it is always drawn at the bottom of the Inspector regardless of other field ordering.

  4. Subsystem creationCreateSubsystem() uses reflection to construct a ParagonSubsystem<T> where T is the concrete behaviour type, passing the target as the owner.

Quick Lookup

Goal
How

Enable subsystem on a behaviour

editor.EnableSubsystem()

Disable subsystem

editor.DisableSubsystem()

Toggle debug mode

editor.SetDebugEnabled(true/false)

Access subsystem property

editor.subsystemProperty (protected)

Properties

subsystemProperty (protected)

The Odin InspectorProperty for the behaviour's subsystem field.

Methods

EnableSubsystem

Creates a new ParagonSubsystem<T> and assigns it to the target behaviour's subsystem field.

Internally constructs ParagonSubsystem<TBehaviourType> via Activator.CreateInstance, passing the target as the constructor argument. Marks the target dirty for serialization.

DisableSubsystem

Nulls out the subsystem field, effectively removing the subsystem from the behaviour.

SetDebugEnabled

Sets the DebugEnabled flag on the target behaviour.

Parameter
Type
Description

value

bool

Whether debug mode should be enabled

No-ops if the value is already the same.

OnCreateGUI (override)

Resolves the subsystem property from the Odin property tree.

OnInspectorGUI (override)

Draws the default Odin Inspector.

Extension Points

Optional Overrides

Method
Purpose

OnCreateGUI()

Resolve additional Odin properties. Call base.OnCreateGUI() to keep subsystem resolution.

OnInspectorGUI()

Customize Inspector rendering. Default calls DrawDefaultInspector().

Implementation Requirements

When subclassing ParagonBehaviourEditor, you MUST:

  1. Call base.OnCreateGUI() if overriding, to ensure subsystemProperty is resolved

  2. Register with [CustomEditor] targeting your specific behaviour type (to override the fallback)

You SHOULD:

  • Keep subsystem management via the inherited EnableSubsystem() / DisableSubsystem() methods

  • Use Tree.RootProperty.Children["fieldName"] to access Odin properties for custom drawing

Examples

Custom Editor for a Specific Behaviour

See Also

Last updated