Table of Contents

Binding to Input Actions

If you use the Input System package, Bindables provides some convenient extensions to bind to InputActions and unbind automatically.

public void InputHandler : MonoBehaviour
{
    public InputAction JumpAction;

    void Start()
    {
        // Bind to onPerformed
        this.BindInputAction(JumpAction, () => Debug.Log("Jump action performed!"));

        // Or, bind to onStarted, onPerformed, and onCanceled
        this.BindInputAction(JumpAction,
            onStarted: () => Debug.Log("Jump action started!"),
            onPerformed: () => Debug.Log("Jump action performed!"),
            onCanceled: () => Debug.Log("Jump action canceled!"),
    }
}