ParagonEditor

Abstract base class for Paragon custom editors. Wraps Odin Inspector's OdinEditor with UI Toolkit support, UXML template auto-loading, element querying helpers, and property tree disposal. Provides both a non-generic base and a generic ParagonEditor<T> variant with typed target access.

Definition

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

public abstract class ParagonEditor : OdinEditor, IDisposable

Inheritance: OdinEditor → ParagonEditor Implements: IDisposable

Generic Variant

public abstract class ParagonEditor<T> : ParagonEditor where T : UnityEngine.Object

Inheritance: OdinEditor → ParagonEditor → ParagonEditor<T>

Remarks

CreateInspectorGUI() is sealed — subclasses cannot override it. Instead, the editor lifecycle routes through:

  1. CreateInspectorGUI() (sealed) — Clones the UXML template (if visualTreeAsset is assigned), creates the root element, adds an IMGUIContainer for OnInspectorGUI(), calls OnCreateGUI(), then schedules Initialize() via EditorApplication.delayCall.

  2. OnCreateGUI() — Override to set up UI elements after the template is cloned.

  3. Initialize() — Override for deferred setup that runs one frame after OnCreateGUI().

  4. OnInspectorGUI() — Override for per-frame IMGUI drawing inside the embedded IMGUIContainer.

Quick Lookup

Goal
How

Create a custom editor

Subclass ParagonEditor<T>, add [CustomEditor(typeof(MyType))]

Assign a UXML template

Set visualTreeAsset in the inspector or via [UxmlTemplate]

Query template elements

Q("elementName") or Q<Button>("elementName")

Access the inspected object

target (typed in generic variant)

Add IMGUI content

Override OnInspectorGUI()

Set up UI after template load

Override OnCreateGUI()

Deferred initialization

Override Initialize()

Fields

Field
Type
Access
Description

visualTreeAsset

VisualTreeAsset

protected

UXML template to clone. Assigned via Inspector. If null, an empty root element is created

rootVisualElement

VisualElement

protected

Root element containing template children and the IMGUI container

Methods

CreateInspectorGUI

Sealed. Creates the inspector UI by cloning the UXML template, adding the IMGUI container, and scheduling initialization.

OnCreateGUI

Virtual callback invoked after the UXML template is cloned and the root element is ready. Override to query template elements and build additional UI.

Initialize

Virtual callback invoked one frame after OnCreateGUI() via EditorApplication.delayCall. Override for setup that requires the visual tree to be fully attached.

OnInspectorGUI

Virtual callback for per-frame IMGUI rendering inside the embedded IMGUIContainer. Defaults to empty (no IMGUI content).

Q

Queries the rootVisualElement for a child element by name.

Dispose

Explicitly disposes the Odin property Tree. Called automatically via IDisposable.

Extension Points

Optional Overrides

Method
Purpose

OnCreateGUI()

Build UI after template cloning — query elements, wire callbacks

Initialize()

Deferred setup one frame after OnCreateGUI()

OnInspectorGUI()

Per-frame IMGUI content inside the embedded container

Implementation Requirements

When subclassing, you MUST:

  1. Add [CustomEditor(typeof(YourType))] to register with Unity

  2. Use the generic ParagonEditor<T> variant for typed target access

You SHOULD:

  • Override OnCreateGUI() to query UXML elements with Q()

  • Use Initialize() for setup that depends on the visual tree being attached

  • Override OnInspectorGUI() only if IMGUI fallback content is needed

You MUST NOT:

  • Override CreateInspectorGUI() — it is sealed

  • Access template elements before OnCreateGUI() is called

Properties (Generic Variant)

Property
Type
Access
Description

target

T

protected

Typed access to the inspected UnityEngine.Object (shadows Editor.target)

Common Pitfalls

circle-exclamation
circle-exclamation

Examples

Custom Editor with UXML Template

Custom Editor with IMGUI Fallback

See Also

Last updated