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:
Toolbox container — A collapsible
Toolboxwith an "+" add button in the header.Component elements — Each
IParagonComponentis rendered as aParagonComponentElement(nested class) with its own collapsible toolbox, remove button, and context menu.Type filtering —
GetSupportedComponentTypes()queriesTypeCachefor all concrete types implementingIParagonComponent<TOwner>that are not already present in the subsystem.MonoBehaviour handling — Components that are
MonoBehaviours are added as actual Unity components on the owner'sGameObjectand 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
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
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
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
MonoBehaviour components hidden from Inspector When a MonoBehaviour is added as a subsystem component, its hideFlags are set to HideInInspector. The component is only visible through the subsystem's custom drawer. If the subsystem is disabled, the MonoBehaviour may remain on the GameObject but be invisible — re-enabling the subsystem will restore visibility.
Null subsystem hides the drawer When the subsystem property is null (subsystem disabled), the entire drawer is hidden via SetDisplay(false). This is expected — the drawer only renders when a subsystem is active.
See Also
ParagonSubsystemSelector — the type picker popup opened by the add button
ParagonBehaviourEditor — the editor that manages the subsystem lifecycle
ParagonBehaviourContextMenu — the header menu for toggling subsystems
Last updated