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
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
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.
label
GUIContent
The label for this property (typically unused)
Common Pitfalls
Negate property excluded from children
The drawer explicitly skips drawing the negate child property in the body because it renders it as a toolbar icon button. If the negate field is renamed in InteractionCondition, this drawer will break (it resolves by name: Property.Children["negate"]).
PolymorphicObjectField for null entries
When the condition is null, SirenixEditorFields.PolymorphicObjectField is used to present a type selector. This requires that condition subclasses are marked [Serializable] and are discoverable by Odin.
See Also
InteractionCondition — the type this drawer renders
InteractionContextDrawer — parent drawer that renders the conditions list
InteractionTableDrawer — top-level table drawer
Last updated