Enum InputActionPhase
Assembly: Unity.InputSystem.dll
public enum InputActionPhase
Fields
Name |
Description |
Canceled |
The action has stopped. Leads to canceled getting called.
By default, a Button action cancels when a control falls back below the button
press threshold (see defaultButtonPressPoint) and a Value
action cancels when a control moves back to its default value. A PassThrough action
does not generally cancel based on input on its controls.
An action will also get canceled when it is disabled while in progress (see Disable()).
Also, when an InputDevice that is
Note that interactions (see IInputInteraction) can alter how an action does or does not progress through
the phases.
|
Disabled |
The action is not enabled.
|
Performed |
The action has been performed. Leads to performed getting called.
By default, a Button action performs when a control crosses the button
press threshold (see defaultButtonPressPoint), a Value
action performs on any value change that isn't the default value, and a PassThrough
action performs on any value change including going back to the default value.
Note that interactions (see IInputInteraction) can alter how an action does or does not progress through
the phases.
For a given action, finding out whether it was performed in the current frame can be done with WasPerformedThisFrame().
action.WasPerformedThisFrame();
|
Started |
An associated control has been actuated such that it may lead to the action
being triggered. Will lead to started getting called.
This phase will only be invoked if there are interactions on the respective control
binding. Without any interactions, an action will go straight from Waiting
into Performed and back into Waiting whenever an associated
control changes value.
An example of an interaction that uses the Started phase is SlowTapInteraction.
When the button it is bound to is pressed, the associated action goes into the Started
phase. At this point, the interaction does not yet know whether the button press will result in just
a tap or will indeed result in slow tap. If the button is released before the time it takes to
recognize a slow tap, then the action will go to Canceled and then back to Waiting.
If, however, the button is held long enough for it to qualify as a slow tap, the action will progress
to Performed and then go back to Waiting.
Started can be useful for UI feedback. For example, in a game where the weapon can be charged,
UI feedback can be initiated when the action is Started.
fireAction.started +=
ctx =>
{
if (ctx.interaction is SlowTapInteraction)
{
weaponCharging = true;
weaponChargeStartTime = ctx.time;
}
}
fireAction.canceled +=
ctx =>
{
weaponCharging = false;
}
fireAction.performed +=
ctx =>
{
Fire();
weaponCharging = false;
}
By default, an action is started as soon as a control moves away from its default value. This is
the case for both Button actions (which, however, does not yet have to mean
that the button press threshold has been reached; see defaultButtonPressPoint)
and Value actions. PassThrough does not use
the Started phase and instead goes straight to Performed.
For Value actions, Started will immediately be followed by Performed.
Note that interactions (see IInputInteraction) can alter how an action does or does not progress through
the phases.
|
Waiting |
The action is enabled and waiting for input on its associated controls.
This is the phase that an action goes back to once it has been Performed
or Canceled.
|
Extension Methods
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.