Interactable
Sealed MonoBehaviour component placed on GameObjects that can receive interactions. Manages an InteractionTable containing the available interactions, and integrates with the Outline system for visual highlight feedback.
Definition
Namespace: Paragon.Townskeep.InteractionSystem Assembly: Townskeep.dll
[RequireComponent(typeof(Outline)), HideMonoScript]
public sealed class Interactable : ParagonBehaviourInheritance: MonoBehaviour → ParagonBehaviour → Interactable
Remarks
Interactable is a sealed class — it cannot be subclassed. Custom interaction behavior is defined by creating Interaction subclasses and configuring them in the InteractionTable via the Inspector.
The component automatically requires an Outline component for hover/selection highlighting. The outline is controlled via SetHighlight(bool).
The InteractionTable is serialized via Odin ([OdinSerialize]), allowing polymorphic serialization of Interaction, InteractionTrigger, and InteractionCondition instances within the table.
Quick Lookup
Check if available
interactable.CanInteractWith(interactor)
Get available interactions
interactable.GetAvailableInteractionsInContext(interactor)
Check if busy
interactable.IsBusy
Highlight on hover
interactable.SetHighlight(true)
Swap interaction table at runtime
interactable.SetInteractionTable(newTable)
Properties
IsBusy
Returns true if an interaction is currently active on this interactable.
IsHighlighted
Returns true if the outline highlight is currently enabled.
Methods
CanInteractWith
Checks whether the interactable is enabled, not busy, and has at least one interaction available for the given interactor.
interactor
Interactor
The entity attempting to interact
Returns: true if the interactable is enabled, not busy, and has available interactions.
GetAvailableInteractionsInContext
Returns all InteractionContext entries whose conditions pass for the given interactor.
interactor
Interactor
The entity to evaluate conditions against
Returns: Enumerable of matching InteractionContext entries.
SetHighlight
Enables or disables the outline highlight effect.
value
bool
true to enable, false to disable
SetInteractionTable
Replaces the interaction table at runtime and initializes the new table.
interactionTable
InteractionTable
The new table to use
GetInteractionTable
Returns the current interaction table.
Returns: The current InteractionTable instance.
OnInteractionBegin
Called by the Interaction lifecycle when an interaction starts. Sets this interactable as busy.
OnInteractionEnd
Called by the Interaction lifecycle when an interaction ends. Clears the busy state.
Common Pitfalls
Missing Outline component Interactable uses [RequireComponent(typeof(Outline))]. The Outline component must be present on the same GameObject. Unity will auto-add it if missing in the Editor, but runtime AddComponent<Interactable>() requires manual attention.
IsBusy blocks all interactions Once an interaction begins, IsBusy returns true and CanInteractWith() returns false for all interactors. Only one interaction can be active at a time per Interactable.
Disabled component blocks interactions CanInteractWith() checks enabled. If the Interactable component is disabled, no interactions will be available.
See Also
Interaction — abstract base for interaction logic
InteractionTable — collection of interaction contexts
Interactor — entity that initiates interactions
Last updated