InteractionConditionDrawer

Odin value drawer for InteractionCondition. Renders each condition as a foldable toolbar panel with a polymorphic type selector for null entries and a negate toggle button.

Definition

Namespace: Paragon.Townskeep.InteractionSystem.Editor Assembly: Townskeep.Editor.dll

[DrawerPriority(0.0, 0.0, 3000.0), UsedImplicitly]
public class InteractionConditionDrawer : OdinValueDrawer<InteractionCondition>

Inheritance: OdinValueDrawer<InteractionCondition>InteractionConditionDrawer

Remarks

This drawer provides a custom Inspector rendering for InteractionCondition instances within the conditions list of an InteractionContext. It handles three distinct visual states:

Visual States

State
Rendering

Null condition

Shows "New Condition" label with a polymorphic type selector field (PolymorphicObjectField)

Condition with no custom fields

Shows the nicified type name as a flat label (no foldout, nothing to expand)

Condition with custom fields

Shows a foldable panel with the type name as header, child fields drawn inside

Negate Toggle

Every condition displays a negate button (exclamation mark icon) in the header toolbar. When the negate flag is active, the button renders in red (Color(1, 0.2, 0.2, 1)), providing clear visual feedback that the condition result is inverted.

The negate property is drawn as a toggle button and excluded from the child property iteration to avoid rendering it twice.

Drawer Priority

The [DrawerPriority(0.0, 0.0, 3000.0)] ensures this drawer takes precedence over Odin's default polymorphic drawer for InteractionCondition values.

Quick Lookup

Goal
How

Create a new condition

Leave the field null — polymorphic selector appears

Toggle negate

Click the exclamation mark icon in the condition header

Expand/collapse fields

Click the foldout arrow (only visible when the condition has custom fields)

Methods

Initialize (override)

Caches the negate child property for the toggle button rendering.

DrawPropertyLayout (override)

Main drawing method. Renders the condition panel with header, negate button, and expandable child fields.

Parameter
Type
Description

label

GUIContent

The label for this property (typically unused)

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated