Class InputAction | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class InputAction

    A named input signal that can flexibly decide which input data to tap.

    Inheritance
    System.Object
    InputAction
    Namespace: UnityEngine.Experimental.Input
    Syntax
    public class InputAction : ICloneable
    Remarks

    Unlike controls, actions signal value changes rather than the values themselves. They sit on top of controls (and each single action may reference several controls collectively) and monitor the system for change.

    Unlike InputControls, InputActions are not passive. They will actively perform processing each frame they are active whereas InputControls just sit there as long as no one is asking them directly for a value.

    Processors on controls are NOT taken into account by actions. A state is considered changed if its underlying memory changes not if the final processed value changes.

    Actions are agnostic to update types. They trigger in whatever update detects a change in value.

    Actions are not supported in edit mode.

    Constructors

    InputAction(String)

    Declaration
    public InputAction(string name = null)
    Parameters
    Type Name Description
    System.String name

    InputAction(String, String, String, String)

    Declaration
    public InputAction(string name = null, string binding = null, string interactions = null, string expectedControlLayout = null)
    Parameters
    Type Name Description
    System.String name
    System.String binding
    System.String interactions
    System.String expectedControlLayout

    Properties

    actionMap

    The map the action belongs to.

    Declaration
    public InputActionMap actionMap { get; }
    Property Value
    Type Description
    InputActionMap
    Remarks

    If the action is a loose action created in code, this will be null.

    bindingMask

    Declaration
    public InputBinding? bindingMask { get; set; }
    Property Value
    Type Description
    System.Nullable<InputBinding>

    bindings

    The list of bindings associated with the action.

    Declaration
    public ReadOnlyArray<InputBinding> bindings { get; }
    Property Value
    Type Description
    ReadOnlyArray<InputBinding>
    Remarks

    This will include only bindings that directly trigger the action. If the action is part of a InputActionMap that triggers the action through a combination of bindings, for example, only the bindings that ultimately trigger the action are included in the list.

    May allocate memory on first hit.

    controls

    The set of controls to which the action's bindings resolve.

    Declaration
    public ReadOnlyArray<InputControl> controls { get; }
    Property Value
    Type Description
    ReadOnlyArray<InputControl>
    Remarks

    May allocate memory each time the control setup changes on the action.

    enabled

    Whether the action is currently enabled or not.

    Declaration
    public bool enabled { get; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    An action is enabled by either calling Enable() on it directly or by calling Enable() on the InputActionMap containing the action. When enabled, an action will listen for changes on the controls it is bound to and trigger ...

    expectedControlLayout

    Name of control layout expected for controls bound to this action.

    Declaration
    public string expectedControlLayout { get; set; }
    Property Value
    Type Description
    System.String
    Remarks

    This is optional and is null by default.

    Constraining an action to a particular control layout allows determine the value type and expected input behavior of an action without being reliant on any particular binding.

    id

    A stable, unique identifier for the action.

    Declaration
    public Guid id { get; }
    Property Value
    Type Description
    Guid
    Remarks

    This can be used instead of the name to refer to the action. Doing so allows referring to the action such that renaming the action does not break references.

    lastTriggerBinding

    Declaration
    public InputBinding lastTriggerBinding { get; }
    Property Value
    Type Description
    InputBinding

    lastTriggerControl

    Declaration
    public InputControl lastTriggerControl { get; }
    Property Value
    Type Description
    InputControl

    lastTriggerDuration

    Declaration
    public double lastTriggerDuration { get; }
    Property Value
    Type Description
    System.Double

    lastTriggerInteraction

    Declaration
    public IInputInteraction lastTriggerInteraction { get; }
    Property Value
    Type Description
    IInputInteraction

    lastTriggerStartTime

    Declaration
    public double lastTriggerStartTime { get; }
    Property Value
    Type Description
    System.Double

    lastTriggerTime

    Declaration
    public double lastTriggerTime { get; }
    Property Value
    Type Description
    System.Double

    name

    Name of the action.

    Declaration
    public string name { get; }
    Property Value
    Type Description
    System.String
    Remarks

    Can be null for anonymous actions created in code.

    If the action is part of a set, it will have a name and the name will be unique in the set.

    The name is just the name of the action alone, not a "setName/actionName" combination.

    phase

    The current phase of the action.

    Declaration
    public InputActionPhase phase { get; }
    Property Value
    Type Description
    InputActionPhase
    Remarks

    When listening for control input and when responding to control value changes, actions will go through several possible phases. TODO

    required

    Declaration
    public bool required { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    Clone()

    Declaration
    public InputAction Clone()
    Returns
    Type Description
    InputAction

    Disable()

    Declaration
    public void Disable()

    Enable()

    Declaration
    public void Enable()

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    Events

    cancelled

    Event that is triggered when the action has been started but then cancelled before being fully performed.

    Declaration
    public event Action<InputAction.CallbackContext> cancelled
    Event Type
    Type Description
    Action<InputAction.CallbackContext>

    performed

    Event that is triggered when the action has been fully performed.

    Declaration
    public event Action<InputAction.CallbackContext> performed
    Event Type
    Type Description
    Action<InputAction.CallbackContext>

    started

    Event that is triggered when the action has been started.

    Declaration
    public event Action<InputAction.CallbackContext> started
    Event Type
    Type Description
    Action<InputAction.CallbackContext>
    Back to top Copyright © 2015-2018 Unity
    Generated by DocFX