InteractionTableDrawer

Odin value drawer for InteractionTable. Renders the table as a list of InteractionContext entries with a custom add function, and provides a "Create Table" button when the table is null. Includes an attribute processor that disables context menus on prefab instances.

Definition

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

[DrawerPriority(0.0, 0.0, 3000.0), DrawerIndentation, UsedImplicitly]
public class InteractionTableDrawer : OdinValueDrawer<InteractionTable>

Inheritance: OdinValueDrawer<InteractionTable>InteractionTableDrawer

Remarks

This drawer handles two visual states for InteractionTable:

State 1: Table is Null

When the InteractionTable value is null (table not yet created), the drawer renders a label with a "Create Table" button. Clicking it instantiates a new InteractionTable().

State 2: Table Exists

When the table has a value, the drawer renders the inner table list property using Odin's built-in collection drawer, but injects a custom add function via CollectionDrawerStaticInfo.NextCustomAddFunction. This ensures that new entries are created as properly constructed InteractionContext instances (with empty trigger/condition lists) rather than default-constructed objects.

Custom Add Function

The AddNewInteractionContext() method:

  1. Retrieves the backing List<InteractionContext> from the table property

  2. Records an undo operation ("Add new Interaction Context")

  3. Creates and adds a new InteractionContext()

  4. Marks the serialization root dirty for save

AttributeProcessor

A nested AttributeProcessor class disables the Odin right-click context menu on prefab instances. This works in tandem with InteractableEditor's read-only enforcement to prevent modification of interaction data on scene instances.

Target
Attribute Added
When

InteractionTable (self)

[DisableContextMenu]

On prefab instances

table field (child)

[DisableContextMenu]

Always (prevents reorder/delete via context menu on the inner list)

Quick Lookup

Goal
How

Create a new interaction table

Click "Create Table" button (when table is null)

Add a new interaction context

Use the list "+" button (custom add function)

Edit interaction contexts

Expand individual entries (rendered by InteractionContextDrawer)

Methods

DrawPropertyLayout (override)

Main drawing method. Handles the null-table state with a "Create Table" button, or delegates to Odin's collection drawer with a custom add function for existing tables.

Parameter
Type
Description

label

GUIContent

The property label (defaults to "Interaction Table" if null)

Nested Types

AttributeProcessor

Odin attribute processor that adds [DisableContextMenu] to prevent unintended modifications via right-click menus on prefab instances.

Methods:

  • ProcessSelfAttributes(...) — adds [DisableContextMenu] to the InteractionTable itself when on a prefab instance

  • ProcessChildMemberAttributes(...) — adds [DisableContextMenu] to the table child field unconditionally

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated