ContinuousInteraction
Custom Unity Input System interaction that fires Performed every frame while the control is actuated. Unlike the default interaction which performs once per press, this enables per-frame input reading — ideal for continuous actions like camera movement, aiming, or analog stick input.
Definition
Namespace: Paragon.Core.InputSystem Assembly: Paragon.dll
[InitializeOnLoad]
[RuntimeInitializeOnLoad]
public class ContinuousInteraction : IInputInteractionImplements: IInputInteraction (UnityEngine.InputSystem)
Remarks
ContinuousInteraction solves a common problem with Unity's Input System: by default, input actions only fire Performed once when the interaction completes (e.g., button press). For continuous input (mouse movement, joystick axes, held buttons), game code needs to read values every frame.
How It Works
Process()is called by the Input System when the action's control changes. If the control is actuated and not yet inPerformed/Startedphase, it callsOnPerformBegin()to start the continuous loop.OnPerformBegin()subscribes toInputSystem.onAfterUpdate, which fires every frame after input processing. This is the key mechanism — theUpdate()method runs each frame.Update()callscontext.PerformedAndStayPerformed()every frame, which keeps the action inPerformedphase and fires theperformedcallback to subscribers. This continues until the control is released.When the control is released,
Cancel()callscontext.Performed()(final perform) thencontext.Canceled(), andOnPerformEnd()unsubscribes from all events.
Safety Subscriptions
The interaction also subscribes to device/layout change events and (in the Editor) play mode state changes. These all trigger Reset(), which ensures the interaction cleans up if the input system state changes unexpectedly — for example, when a device is disconnected or the user exits play mode.
Quick Lookup
Apply to an action
Set the interaction to ContinuousInteraction in the Input Action Asset
Read value every frame
Subscribe to action.performed — it fires every frame while held
Registration
Automatic via [InitializeOnLoad] and [RuntimeInitializeOnLoad]
Methods
Process
Called by the Input System when the bound control changes state. Routes to either Cancel() (control released) or OnPerformBegin() (control actuated).
context
ref InputInteractionContext
The interaction context from the Input System
Behavior:
If control is not actuated: calls
Cancel()to end the interactionIf control is actuated and phase is not
Performed/Started: callsOnPerformBegin()to start the per-frame loop
Reset
Called by the Input System when the interaction needs to be reset. Unsubscribes from all frame events via OnPerformEnd().
Update (private)
Called every frame via InputSystem.onAfterUpdate. Checks if the interaction should continue and calls PerformedAndStayPerformed() to fire the performed callback.
Behavior:
If phase is
Canceled,Disabled, action map is disabled, or control is not actuated: callsCancel()If phase is
Performed,Started, orWaiting: callscontext.PerformedAndStayPerformed()
Cancel (private)
Ends the continuous interaction. Calls OnPerformEnd(), then fires a final Performed() followed by Canceled() if the phase was active.
OnPerformBegin (private)
Subscribes to per-frame and safety events to start the continuous loop.
Subscribes to:
InputSystem.onAfterUpdate— per-frameUpdate()callsInputSystem.onLayoutChange— layout change safety resetInputSystem.onDeviceChange— device change safety resetEditorApplication.playModeStateChanged— editor play mode safety reset (editor only)
OnPerformEnd (private)
Unsubscribes from all events registered by OnPerformBegin().
Common Pitfalls
Performed fires every frame Unlike default interactions, performed fires continuously — not just once. Subscribers that expect a single trigger per press (e.g., toggling a boolean) will fire repeatedly. Use started for one-shot press detection instead.
Must be registered before use The interaction registers itself via a static constructor with InputSystem.RegisterInteraction<ContinuousInteraction>(). If accessed before the static constructor runs (unlikely due to [InitializeOnLoad]), the interaction will not appear in the Input Action Asset editor.
Device disconnection resets the interaction If a device is disconnected or the input layout changes, Reset() is called via the safety subscriptions. This may cause unexpected cancellation of ongoing continuous actions.
Examples
Using in an Input Action Asset
In the Unity Input Action Asset editor:
Select an action (e.g., "Look", "Move")
Add an interaction → select
ContinuousInteractionThe
performedcallback will now fire every frame while the control is actuated
Reading Continuous Input
See Also
Interactions Overview — subfolder overview
InputSystem Overview — parent system
Last updated