ActionDrawer

Generic Odin property drawer for all Action-derived types. Renders a toolbar header with a polymorphic type selector, a foldable body displaying action variables, and an optional progress indicator that animates while the action is running.

Definition

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

[DrawerPriority(0.0, 0.0, 3000.0)]
[DrawerIndentation]
public class ActionDrawer<TAction> : OdinValueDrawer<TAction>
    where TAction : Action

Inherits: OdinValueDrawer<TAction> (Sirenix.OdinInspector.Editor) Type Constraint: TAction : Action

Remarks

This is the base editor drawer for the entire Action System hierarchy. It handles three responsibilities:

  1. Header — A horizontal toolbar containing a foldout toggle and a PolymorphicObjectField for type selection. This allows users to pick any concrete Action subclass from a dropdown.

  2. Progress Indicator — An animated bar that pulses while IsRunning is true, providing visual feedback during Play Mode.

  3. Body — A foldable section that draws the action's actionVariables child property (the fields marked with [Variable]).

The drawer uses DrawerPriority(0, 0, 3000) so it takes precedence over Odin's default drawers. Subclass drawers (e.g., ActionSequenceDrawer) use higher priorities to override this drawer for more specific types.

Quick Lookup

Goal
How

Customize the foldout label

Override defaultLabel property

Change header rendering

Override DrawHeader(GUIContent)

Change body rendering

Override DrawBody()

Hide progress indicator

Set showProgressIndicator = false in Initialize()

Check if action is running

Read isRunning property

Properties

defaultLabel

The default GUIContent label shown when no label is provided by the property. Defaults to "Action".

isRunning

Returns whether the drawn action is currently executing. Reads from ValueEntry.SmartValue.IsRunning.

Fields

isExpanded

Controls whether the body foldout is expanded. Defaults to true.

showProgressIndicator

Controls whether the animated progress indicator is shown. Defaults to true. Set to false in Initialize() to hide it.

Methods

DrawPropertyLayout

Main entry point called by Odin. Draws the header, optional progress indicator, and body in a vertical layout.

Parameter
Type
Description

label

GUIContent

Label from the serialized property. Falls back to defaultLabel if null.

DrawHeader

Draws the toolbar header containing the foldout toggle and polymorphic object field.

Parameter
Type
Description

label

GUIContent

Label to display. Automatically nicified via ObjectNames.NicifyVariableName().

Behavior:

  • If SmartValue is null: shows a prefix label with no foldout (collapsed).

  • If SmartValue is set: shows a SirenixEditorGUI.Foldout controlling isExpanded.

  • Always renders SirenixEditorFields.PolymorphicObjectField for type selection/assignment.

DrawBody

Draws the foldable body containing the action's actionVariables child property.

Behavior:

  • Wraps content in a SirenixEditorGUI.BeginFadeGroup / EndFadeGroup controlled by isExpanded.

  • Draws the actionVariables child property inside a horizontal toolbar with indentation.

Extension Points

Required Overrides

None — ActionDrawer is a concrete class.

Optional Overrides

Method / Property
Purpose

defaultLabel

Change the default foldout label text

DrawHeader(GUIContent)

Customize the toolbar header (type selector, foldout, extra buttons)

DrawBody()

Customize what is drawn inside the foldable body

Initialize()

One-time setup (e.g., set showProgressIndicator = false)

Implementation Requirements

When subclassing ActionDrawer<TAction>, you MUST:

  1. Use a higher DrawerPriority than 3000 (otherwise Odin will pick this drawer instead)

  2. Constrain TAction to your custom Action subclass (e.g., where T : MyAction)

You SHOULD:

  • Call base.DrawHeader(label) if you only want to append to the header

  • Call base.DrawBody() if you want to extend (not replace) the body

  • Set showProgressIndicator in Initialize(), not in DrawPropertyLayout()

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

Examples

Custom Drawer for a Specific Action Type

Drawer Without Progress Indicator

See Also

Last updated