InputSystem

Attribute-driven input binding framework built on top of Unity's Input System package. Provides a declarative, reflection-based approach to connecting input actions to handler methods — subclass InputActionMapBinding, mark methods with [InputActionCallback], and the system auto-discovers and wires up bindings with automatic type conversion.

Architecture

spinner

Data Flow

spinner

Key Concepts

Concept
Description

InputActionScheme

MonoBehaviour that holds a Unity InputActionAsset and its binding handlers. The root entry point.

InputActionMapBinding

Abstract base class — subclass to define input handlers for one action map. Methods marked with [InputActionCallback] are auto-discovered.

InputActionCallback

Delegate wrapper that auto-converts between method signatures (Action, Action<CallbackContext>, Action<T>) for Unity's input callback system.

InputActionCallbackAttribute

Method attribute specifying which input action and phase a handler responds to.

InputActionPhase

Enum mapping to Unity's input phases: STARTED, PERFORMED, CANCELLED.

Quick Start

1. Create a binding class

2. Assign in the Inspector

Attach an InputActionScheme component to a GameObject, assign a Unity InputActionAsset, and the system will create binding slots for each action map. Assign your PlayerMovementBinding to the corresponding action map slot.

3. Enable at runtime

Supported Callback Signatures

Signature
Behavior

void Method()

Called on input; CallbackContext is discarded

void Method(InputAction.CallbackContext ctx)

Called with full context — no wrapping needed

void Method(Vector2 value)

Auto-extracts via ctx.ReadValue<Vector2>()

void Method(float value)

Auto-extracts via ctx.ReadValue<float>()

Any void Method(T value) where T : struct

Auto-extracts via ctx.ReadValue<T>()

Classes

Class
Description

MonoBehaviour root — holds the InputActionAsset and manages bindings

Abstract base for declaring input handlers via attributes

Delegate wrapper with automatic type conversion

Method attribute for declaring input action handlers

Enum for input action phases

See Also

Last updated