ParagonSubsystemDrawer

Odin property drawer that renders a ParagonSubsystem using UI Toolkit. Displays the subsystem's IParagonComponent collection as a list of expandable toolbox elements with add/remove workflow, right-click context menus, and configurable display delegates.

Definition

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

[DrawerPriority(DrawerPriorityLevel.SuperPriority)]
[UxmlTemplate("ParagonSubsystemElement")]
public class ParagonSubsystemDrawer : ParagonVisualElementDrawer<ParagonSubsystem>

Inheritance: OdinValueDrawer<ParagonSubsystem>ParagonDrawer<ParagonSubsystem>ParagonVisualElementDrawer<ParagonSubsystem>ParagonSubsystemDrawer

Remarks

This drawer replaces the default Odin property drawing for ParagonSubsystem with a fully custom UI Toolkit-based layout:

  1. Toolbox container — A collapsible Toolbox with an "+" add button in the header.

  2. Component elements — Each IParagonComponent is rendered as a ParagonComponentElement (nested class) with its own collapsible toolbox, remove button, and context menu.

  3. Type filteringGetSupportedComponentTypes() queries TypeCache for all concrete types implementing IParagonComponent<TOwner> that are not already present in the subsystem.

  4. MonoBehaviour handling — Components that are MonoBehaviours are added as actual Unity components on the owner's GameObject and hidden from the default Inspector (HideFlags.HideInInspector).

The drawer is configured with DrawerPriorityLevel.SuperPriority to ensure it takes precedence over other drawers, and uses [UxmlTemplate("ParagonSubsystemElement")] for its UXML layout.

Quick Lookup

Goal
How

Customize component display names

Set drawer.NameGetter = type => "..."

Customize component ordering

Set drawer.PriorityGetter = type => priority

Customize component icons

Set drawer.IconGetter = type => ParagonIconType.X

Control remove button availability

Set drawer.CanBeRemovedGetter = type => bool

Properties

Configuration Delegates

Field
Type
Default
Description

NameGetter

Func<Type, string>

ObjectNames.NicifyVariableName(type.Name)

Returns the display name for a component type

PriorityGetter

Func<Type, int>

null (no ordering)

Returns the sort priority for a component type

IconGetter

Func<Type, ParagonIconType>

null (defaults to LAYERS)

Returns the icon for a component type

CanBeRemovedGetter

Func<Type, bool>

null (defaults to true)

Returns whether a component type can be removed

Methods

OnCreateGUI (override)

Builds the UI Toolkit layout: Toolbox with add button, component container, and initial Rebuild().

OnInspectorGUI (override)

Checks if the subsystem reference changed and triggers a Rebuild() if so.

AddComponent (private)

Adds a component of the given type to the subsystem. If the type is a MonoBehaviour, adds it to the owner's GameObject; otherwise creates it via Activator.CreateInstance.

RemoveComponent (private)

Removes a component of the given type from the subsystem. If it's a MonoBehaviour, also DestroyImmediates the Unity component.

Extension Points

Optional Overrides

Method
Purpose

OnCreateGUI()

Customize the UI Toolkit layout. Call base.OnCreateGUI() to keep default behaviour.

OnInspectorGUI()

Add per-frame IMGUI logic. Call base.OnInspectorGUI() to keep change detection.

Configuration via Delegates

The drawer's appearance and behaviour are configured by setting the public delegate fields. These are typically set by a higher-level drawer or editor that knows the domain-specific display rules:

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated