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:
Retrieves the backing
List<InteractionContext>from thetablepropertyRecords an undo operation ("Add new Interaction Context")
Creates and adds a
new InteractionContext()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.
InteractionTable (self)
[DisableContextMenu]
On prefab instances
table field (child)
[DisableContextMenu]
Always (prevents reorder/delete via context menu on the inner list)
Quick Lookup
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.
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 theInteractionTableitself when on a prefab instanceProcessChildMemberAttributes(...)— adds[DisableContextMenu]to thetablechild field unconditionally
Common Pitfalls
CollectionDrawerStaticInfo.NextCustomAddFunction is global state
The custom add function is set via a static property on CollectionDrawerStaticInfo. It is consumed (cleared) by the next Odin collection drawer that renders. If the draw order changes or the property is consumed by a different collection, the add function may not apply to the intended list.
Table field resolved by name
The inner list property is resolved via Property.Children["table"]. If the backing field in InteractionTable is renamed, this drawer will break.
Undo support requires serialization root dirty
AddNewInteractionContext() calls both RecordForUndo() and MarkSerializationRootDirty() to ensure Odin properly tracks the change. If either is missing, undo or save may not function correctly.
See Also
InteractionTable — the type this drawer renders
InteractionContextDrawer — draws individual context entries within the table
InteractionConditionDrawer — draws conditions within each context
InteractableEditor — the editor that hosts this drawer
Last updated