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

    Class InputActionMap

    A mapping of InputBinding to InputAction.

    Inheritance
    System.Object
    InputActionMap
    Namespace: UnityEngine.Experimental.Input
    Syntax
    public class InputActionMap : ICloneable, ISerializationCallbackReceiver, IInputActionCollection, IEnumerable<InputAction>
    Remarks

    Also stores data for actions. All actions have to have an associated action map. "Lose" actions constructed without a map will internally create their own map to hold their data.

    A common usage pattern for action maps is to use them to group action "contexts". So one map could hold "menu" actions, for example, whereas another set holds "gameplay" actions. This kind of splitting can be made arbitrarily complex. Like, you could have separate "driving" and "walking" action maps, for example, that you enable and disable depending on whether the player is walking or driving around.

    Constructors

    InputActionMap(String, InputActionMap)

    Declaration
    public InputActionMap(string name = null, InputActionMap extend = null)
    Parameters
    Type Name Description
    System.String name
    InputActionMap extend

    Properties

    actions

    List of actions contained in the map.

    Declaration
    public ReadOnlyArray<InputAction> actions { get; }
    Property Value
    Type Description
    ReadOnlyArray<InputAction>
    Remarks

    Actions are owned by their map. The same action cannot appear in multiple maps.

    Does not allocate. Note that values returned by the property become invalid if the setup of actions in a set is changed.

    asset

    If the action map is part of an asset, this refers to the asset. Otherwise it is null.

    Declaration
    public InputActionAsset asset { get; }
    Property Value
    Type Description
    InputActionAsset

    bindingMask

    Optional mask applied to all bindings in the collection.

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

    If this is not null, only bindings that match the mask will be used.

    bindings

    List of bindings contained in the map.

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

    InputBinding are owned by action maps and not by individual actions. The bindings in a map can form a tree and conceptually, this array represents a depth-first traversal of the tree.

    Bindings that trigger actions refer to the action by name.

    controlSchemes

    Declaration
    public ReadOnlyArray<InputControlScheme> controlSchemes { get; }
    Property Value
    Type Description
    ReadOnlyArray<InputControlScheme>
    Implements
    IInputActionCollection.controlSchemes

    devices

    Devices to use with the actions in this collection.

    Declaration
    public ReadOnlyArray<InputDevice>? devices { get; set; }
    Property Value
    Type Description
    System.Nullable<ReadOnlyArray<InputDevice>>
    Implements
    IInputActionCollection.devices
    Remarks

    If this is set, actions in the collection will exclusively bind to devices in the given list. For example, if two gamepads are present in the system yet only one gamepad is listed here, then a "<Gamepad>/leftStick" binding will only bind to the gamepad in the list and not to the one that is only available globally.

    enabled

    Whether any action in the map is currently enabled.

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

    id

    A stable, unique identifier for the map.

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

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

    Item[String]

    Declaration
    public InputAction this[string actionNameOrId] { get; }
    Parameters
    Type Name Description
    System.String actionNameOrId
    Property Value
    Type Description
    InputAction

    name

    Name of the action map.

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

    Methods

    Clone()

    Declaration
    public InputActionMap Clone()
    Returns
    Type Description
    InputActionMap

    Contains(InputAction)

    Declaration
    public bool Contains(InputAction action)
    Parameters
    Type Name Description
    InputAction action
    Returns
    Type Description
    System.Boolean
    Implements
    IInputActionCollection.Contains(InputAction)

    Disable()

    Disable all the actions in the map.

    Declaration
    public void Disable()
    Implements
    IInputActionCollection.Disable()

    Enable()

    Enable all the actions in the map.

    Declaration
    public void Enable()
    Implements
    IInputActionCollection.Enable()

    FromJson(String)

    Declaration
    public static InputActionMap[] FromJson(string json)
    Parameters
    Type Name Description
    System.String json
    Returns
    Type Description
    InputActionMap[]

    GetAction(Guid)

    Declaration
    public InputAction GetAction(Guid id)
    Parameters
    Type Name Description
    Guid id
    Returns
    Type Description
    InputAction

    GetAction(String)

    Declaration
    public InputAction GetAction(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    InputAction

    GetEnumerator()

    Enumerate the actions in the map.

    Declaration
    public IEnumerator<InputAction> GetEnumerator()
    Returns
    Type Description
    IEnumerator<InputAction>

    An enumerator going over the actions in the map.

    Remarks

    This method supports to generically iterate over the actions in a map. However, it will usually lead to GC allocation. Iterating directly over actions avoids allocating GC memory.

    OnAfterDeserialize()

    Declaration
    public void OnAfterDeserialize()

    OnBeforeSerialize()

    Declaration
    public void OnBeforeSerialize()

    ToJson()

    Declaration
    public string ToJson()
    Returns
    Type Description
    System.String

    ToJson(IEnumerable<InputActionMap>)

    Declaration
    public static string ToJson(IEnumerable<InputActionMap> sets)
    Parameters
    Type Name Description
    IEnumerable<InputActionMap> sets
    Returns
    Type Description
    System.String

    ToString()

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

    TryGetAction(Guid)

    Declaration
    public InputAction TryGetAction(Guid id)
    Parameters
    Type Name Description
    Guid id
    Returns
    Type Description
    InputAction

    TryGetAction(String)

    Declaration
    public InputAction TryGetAction(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    InputAction

    Events

    actionTriggered

    Add or remove a callback that is triggered when an action in the map changes its InputActionPhase.

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