InteractableEditor

Custom Unity Inspector editor for Interactable. Enforces read-only display for prefab instances and provides a button to open the prefab asset for modification.

Definition

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

[CustomEditor(typeof(Interactable))]
public class InteractableEditor : OdinEditor

Inheritance: OdinEditorInteractableEditor

Remarks

InteractableEditor exists to prevent accidental modification of Interactable properties on prefab instances in scenes. The Interaction System's data (triggers, conditions, interactions) is authored on the prefab asset, not on instances, because InteractionTable uses Odin polymorphic serialization which does not support prefab overrides cleanly.

Behavior

Scenario
Inspector Behavior

Prefab asset (editing prefab directly)

Normal Odin Inspector — fully editable

Prefab instance (in scene)

Read-only + "Open Prefab Asset for Modification" button

Non-prefab instance

Normal Odin Inspector — fully editable

The prefab detection uses Tree.PrefabModificationHandler.HasPrefabs from Odin's API. When a prefab instance is detected, the entire Inspector is wrapped in DrawGUI.ReadonlyIf(true), and a toolbar button is rendered that opens the source prefab asset via AssetDatabase.OpenAsset().

Quick Lookup

Goal
How

Edit interactable properties

Open the prefab asset (not the scene instance)

Override on scene instance

Not supported — button redirects to prefab

Methods

OnInspectorGUI (override)

Draws the default Odin Inspector, wrapping it in read-only mode for prefab instances. Appends an "Open Prefab Asset" button when on a prefab instance.

Behavior:

  1. Checks Tree.PrefabModificationHandler.HasPrefabs

  2. If prefab instance: draws all properties as read-only, then renders the "Open Prefab Asset for Modification" toolbar button

  3. If not a prefab instance: draws properties normally (default Odin rendering)

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated