Input

Attribute-driven input binding subsystem for the Interaction System. Provides a declarative way to bind Unity Input System actions to methods on Interaction subclasses — mark methods with [InteractionInput], and the InteractionInputTable auto-discovers, registers, and manages bindings for the interaction's lifetime.

Architecture

spinner

Data Flow

spinner

Key Concepts

Concept
Description

InteractionInputTable

Collection that auto-discovers [InteractionInput]-attributed methods on an Interaction subclass and manages their lifecycle.

InteractionInput

Individual input binding — wraps a Unity InputActionReference and invokes registered callbacks when the configured phase fires.

InteractionInputAttribute

Method attribute declaring an interaction input handler with a name and phase.

InteractionInputPhase

Enum for input phases: STARTED, PERFORMED, CANCELED.

Quick Start

1. Define inputs on an Interaction subclass

using Paragon.Townskeep.InteractionSystem;

[Serializable]
public class ChopTreeInteraction : Interaction
{
    [InteractionInput("Chop")]
    private void OnChop()
    {
        // Called when the "Chop" input is performed
        Debug.Log("Chop!");
    }

    [InteractionInput("Cancel", InteractionInputPhase.STARTED)]
    private void OnCancel()
    {
        // Called when "Cancel" input starts
        Cancel();
    }
}

2. Configure in Inspector

The InteractionInputTable serializes each discovered input as an InteractionInput entry. In the Inspector, assign an InputActionReference and configure the phase for each entry.

3. Runtime lifecycle

Inputs are automatically bound when the interaction begins (if the interactor has input control) and unbound when it completes or is cancelled. No manual binding is needed.

Classes

Class
Description

Individual input binding wrapping a Unity InputActionReference

Method attribute for declaring interaction input handlers

Enum for input action phases

Reflection-based collection managing all inputs for an Interaction

See Also

Last updated