ActionVariableDrawer

Custom Odin Inspector drawer for individual ActionVariable instances. Renders either an inline value editor or a reference label depending on the variable's mode, and provides toggle and delete controls.

Definition

Namespace: Paragon.Core.ActionSystem.Editor Assembly: Paragon.Editor.dll

[DrawerPriority(0.0, 0.0, 3000.0)]
public class ActionVariableDrawer : OdinValueDrawer<ActionVariable>

Inherits: OdinValueDrawer<ActionVariable>

Remarks

This drawer is automatically resolved by Odin for any ActionVariable property in the Inspector. It renders each variable in a toolbar-style row with three sections:

  1. Value area — either an inline property field (direct value mode) or a styled reference label with dropdown (reference mode).

  2. Link toggle — a toggle button that switches between direct-value and reference modes, calling ActionVariable.IsReference and clearing the unused binding.

  3. Delete button — removes the variable from its parent ActionVariables container, but only for dynamic variables (field variables are non-removable).

The drawer priority is set to 3000.0 (wrapper priority) to ensure it takes precedence over default drawers.

Quick Lookup

Goal
How

Toggle reference mode

Click the link icon button (cyan = reference, gray = direct value)

Select a reference

Click the dropdown arrow in reference mode → opens ActionVariableReferenceMenu

Delete a variable

Click the trash icon (only enabled for dynamic variables)

Lifecycle

Initialize

Called once when the drawer is first created. Sets up:

  • variable — the ActionVariable being drawn

  • valueProperty — the child InspectorProperty for the variable's Value field

  • isRemovabletrue only if the variable is not a field variable (!variable.IsFieldVariable)

  • referenceMenu — a new ActionVariableReferenceMenu instance bound to this drawer

DrawPropertyLayout

Main draw method called every Inspector GUI frame. The label text is nicified via ObjectNames.NicifyVariableName() before rendering.

Drawing Modes

Direct Value Mode (IsReference == false)

Renders the variable's Value property using Odin's standard property drawing. Respects the current drawer indentation level.

Reference Mode (IsReference == true)

Renders a cyan-colored box showing:

  • The referenced variable's nicified name (or "No Variable Selected" if unbound)

  • A dropdown arrow button that opens the ActionVariableReferenceMenu

Controls

A toggle button with a link icon that switches between direct-value and reference modes.

State
Appearance

Direct value mode

Gray link icon

Reference mode

Cyan link icon

When toggled:

  • Marks the serialization root dirty for undo/save

  • Sets variable.IsReference to the new value

  • Clears the unused binding: reference mode clears the direct value (SetValue(default)), direct mode clears the reference (SetReference(default))

Delete Button

A red trash icon button that removes the variable from its parent ActionVariables container.

State
Appearance
Behavior

Dynamic variable

Red trash icon (enabled)

Calls ActionVariables.RemoveVariable(variable.Name)

Field variable

Gray trash icon (read-only)

Button is disabled

The delete operation walks up the property tree to find the parent actionVariables property and calls RemoveVariable() on it.

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated