Class InputActionSetupExtensions | Input System | 1.0.2
docs.unity.cn
    Show / Hide Table of Contents

    Class InputActionSetupExtensions

    Methods to change the setup of InputAction, InputActionMap, and InputActionAsset objects.

    Inheritance
    Object
    InputActionSetupExtensions
    Namespace: UnityEngine.InputSystem
    Syntax
    public static class InputActionSetupExtensions
    Remarks

    Unlike the methods in InputActionRebindingExtensions, the methods here are generally destructive, i.e. they will rearrange the data for actions.

    Methods

    AddAction(InputActionMap, String, InputActionType, String, String, String, String, String)

    Declaration
    public static InputAction AddAction(this InputActionMap map, string name, InputActionType type = InputActionType.Value, string binding = null, string interactions = null, string processors = null, string groups = null, string expectedControlLayout = null)
    Parameters
    Type Name Description
    InputActionMap map
    String name
    InputActionType type
    String binding
    String interactions
    String processors
    String groups
    String expectedControlLayout
    Returns
    Type Description
    InputAction

    AddActionMap(InputActionAsset, String)

    Create an action map with the given name and add it to the asset.

    Declaration
    public static InputActionMap AddActionMap(this InputActionAsset asset, string name)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to add the action map to

    String name

    Name to assign to the

    Returns
    Type Description
    InputActionMap

    The newly added action map.

    Exceptions
    Type Condition
    ArgumentNullException

    asset is null or InvalidOperationException name is null or empty.

    AddActionMap(InputActionAsset, InputActionMap)

    Add an action map to the asset.

    Declaration
    public static void AddActionMap(this InputActionAsset asset, InputActionMap map)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to add the map to.

    InputActionMap map

    A named action map.

    Exceptions
    Type Condition
    ArgumentNullException

    map or asset is null.

    InvalidOperationException

    map has no name or asset already contains a map with the same name.

    See Also
    actionMaps

    AddBinding(InputAction, String, String, String, String)

    Add a new binding to the given action.

    Declaration
    public static InputActionSetupExtensions.BindingSyntax AddBinding(this InputAction action, string path, string interactions = null, string processors = null, string groups = null)
    Parameters
    Type Name Description
    InputAction action

    Action to add the binding to. If the action is part of an InputActionMap, the newly added binding will be visible on bindings.

    String path

    Binding path string. See path for details.

    String interactions

    Optional list of interactions to apply to the binding. See interactions for details.

    String processors

    Optional list of processors to apply to the binding. See processors for details.

    String groups

    Optional list of binding groups that should be assigned to the binding. See groups for details.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    Fluent-style syntax to further configure the binding.

    AddBinding(InputAction, InputBinding)

    Add a new binding to the action.

    Declaration
    public static InputActionSetupExtensions.BindingSyntax AddBinding(this InputAction action, InputBinding binding = default(InputBinding))
    Parameters
    Type Name Description
    InputAction action

    An action to add the binding to.

    InputBinding binding

    Binding to add to the action or default. Binding can be further configured via the struct returned by the method.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    Returns a fluent-style syntax structure that allows performing additional modifications based on the new binding.

    Remarks

    This works both with actions that are part of an action set as well as with actions that aren't.

    Note that actions must be disabled while altering their binding sets. Also, if the action belongs to a set, all actions in the set must be disabled.

    fireAction.AddBinding()
        .WithPath("<Gamepad>/buttonSouth")
        .WithGroup("Gamepad");

    AddBinding(InputAction, InputControl)

    Add a binding that references the given control and triggers the given .

    Declaration
    public static InputActionSetupExtensions.BindingSyntax AddBinding(this InputAction action, InputControl control)
    Parameters
    Type Name Description
    InputAction action

    Action to trigger.

    InputControl control

    Control to bind to. The full path of the control will be used in the resulting InputBinding.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    Syntax to configure the binding further.

    Exceptions
    Type Condition
    ArgumentNullException

    action is null or control is null.

    See Also
    bindings

    AddBinding(InputActionMap, String, Guid, String, String)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax AddBinding(this InputActionMap actionMap, string path, Guid action, string interactions = null, string groups = null)
    Parameters
    Type Name Description
    InputActionMap actionMap
    String path
    Guid action
    String interactions
    String groups
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    AddBinding(InputActionMap, String, String, String, String)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax AddBinding(this InputActionMap actionMap, string path, string interactions = null, string groups = null, string action = null)
    Parameters
    Type Name Description
    InputActionMap actionMap
    String path
    String interactions
    String groups
    String action
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    AddBinding(InputActionMap, String, InputAction, String, String)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax AddBinding(this InputActionMap actionMap, string path, InputAction action, string interactions = null, string groups = null)
    Parameters
    Type Name Description
    InputActionMap actionMap
    String path
    InputAction action
    String interactions
    String groups
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    AddBinding(InputActionMap, InputBinding)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax AddBinding(this InputActionMap actionMap, InputBinding binding)
    Parameters
    Type Name Description
    InputActionMap actionMap
    InputBinding binding
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    AddCompositeBinding(InputAction, String, String, String)

    Declaration
    public static InputActionSetupExtensions.CompositeSyntax AddCompositeBinding(this InputAction action, string composite, string interactions = null, string processors = null)
    Parameters
    Type Name Description
    InputAction action
    String composite
    String interactions
    String processors
    Returns
    Type Description
    InputActionSetupExtensions.CompositeSyntax

    AddControlScheme(InputActionAsset, String)

    Add a new control scheme to the given asset.

    Declaration
    public static InputActionSetupExtensions.ControlSchemeSyntax AddControlScheme(this InputActionAsset asset, string name)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to add the control scheme to.

    String name

    Name to give to the control scheme. Must be unique within the control schemes of the asset. Also used as default name of bindingGroup associated with the control scheme.

    Returns
    Type Description
    InputActionSetupExtensions.ControlSchemeSyntax

    Syntax to allow providing additional configuration for the newly added control scheme.

    Exceptions
    Type Condition
    ArgumentNullException

    asset is null -or- name is null or empty.

    AddControlScheme(InputActionAsset, InputControlScheme)

    Add a new control scheme to the asset.

    Declaration
    public static void AddControlScheme(this InputActionAsset asset, InputControlScheme controlScheme)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to add the control scheme to.

    InputControlScheme controlScheme

    Control scheme to add.

    Exceptions
    Type Condition
    ArgumentException

    controlScheme has no name.

    ArgumentNullException

    asset is null.

    InvalidOperationException

    A control scheme with the same name as controlScheme already exists in the asset.

    ChangeBinding(InputAction, Int32)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax ChangeBinding(this InputAction action, int index)
    Parameters
    Type Name Description
    InputAction action
    Int32 index
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    ChangeBinding(InputAction, InputBinding)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax ChangeBinding(this InputAction action, InputBinding match)
    Parameters
    Type Name Description
    InputAction action
    InputBinding match
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    ChangeBindingWithGroup(InputAction, String)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax ChangeBindingWithGroup(this InputAction action, string group)
    Parameters
    Type Name Description
    InputAction action
    String group
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    ChangeBindingWithId(InputAction, Guid)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax ChangeBindingWithId(this InputAction action, Guid id)
    Parameters
    Type Name Description
    InputAction action
    Guid id
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    ChangeBindingWithId(InputAction, String)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax ChangeBindingWithId(this InputAction action, string id)
    Parameters
    Type Name Description
    InputAction action
    String id
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    ChangeBindingWithPath(InputAction, String)

    Declaration
    public static InputActionSetupExtensions.BindingSyntax ChangeBindingWithPath(this InputAction action, string path)
    Parameters
    Type Name Description
    InputAction action
    String path
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    OrWithOptionalDevice(InputControlScheme, String)

    Declaration
    public static InputControlScheme OrWithOptionalDevice(this InputControlScheme scheme, string controlPath)
    Parameters
    Type Name Description
    InputControlScheme scheme
    String controlPath
    Returns
    Type Description
    InputControlScheme

    OrWithRequiredDevice(InputControlScheme, String)

    Declaration
    public static InputControlScheme OrWithRequiredDevice(this InputControlScheme scheme, string controlPath)
    Parameters
    Type Name Description
    InputControlScheme scheme
    String controlPath
    Returns
    Type Description
    InputControlScheme

    RemoveAction(InputAction)

    Remove the given action from its InputActionMap.

    Declaration
    public static void RemoveAction(this InputAction action)
    Parameters
    Type Name Description
    InputAction action

    An input action that is part of an InputActionMap.

    Remarks

    After removal, the action's actionMap will be set to null and the action will effectively become a standalone action that is not associated with any action map. Bindings on the action will be preserved. On the action map, the bindings for the action will be removed.

    Exceptions
    Type Condition
    ArgumentNullException

    action is null.

    ArgumentException

    action is part of an InputActionMap that has at least one enabled action -or- action is a standalone action that is not part of an InputActionMap and thus cannot be removed from anything.

    See Also
    AddAction(InputActionMap, String, InputActionType, String, String, String, String, String)

    RemoveAction(InputActionAsset, String)

    Remove the action with the given name from the asset.

    Declaration
    public static void RemoveAction(this InputActionAsset asset, string nameOrId)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to remove the action from.

    String nameOrId

    Name or ID of the action. See FindAction(String, Boolean) for details.

    Exceptions
    Type Condition
    ArgumentNullException

    asset is null -or- nameOrId is null or empty.

    See Also
    RemoveAction(InputAction)

    RemoveActionMap(InputActionAsset, String)

    Remove the action map with the given name or ID from the asset.

    Declaration
    public static void RemoveActionMap(this InputActionAsset asset, string nameOrId)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to remove the action map from.

    String nameOrId

    The name or ID (see id) of a map in the asset. Note that lookup is case-insensitive. If no map with the given name or ID is found, the method does nothing.

    Exceptions
    Type Condition
    ArgumentNullException

    asset or nameOrId is null.

    InvalidOperationException

    The map referenced by nameOrId is currently enabled (see enabled).

    See Also
    RemoveActionMap(InputActionAsset, String)
    actionMaps

    RemoveActionMap(InputActionAsset, InputActionMap)

    Remove the given action map from the asset.

    Declaration
    public static void RemoveActionMap(this InputActionAsset asset, InputActionMap map)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to add the action map to.

    InputActionMap map

    An action map. If the given map is not part of the asset, the method does nothing.

    Exceptions
    Type Condition
    ArgumentNullException

    asset or map is null.

    InvalidOperationException

    map is currently enabled (see enabled).

    See Also
    RemoveActionMap(InputActionAsset, String)
    actionMaps

    RemoveControlScheme(InputActionAsset, String)

    Remove the control scheme with the given name from the asset.

    Declaration
    public static void RemoveControlScheme(this InputActionAsset asset, string name)
    Parameters
    Type Name Description
    InputActionAsset asset

    Asset to remove the control scheme from.

    String name

    Name of the control scheme. Matching is case-insensitive.

    Remarks

    If no control scheme with the given name can be found, the method does nothing.

    Exceptions
    Type Condition
    ArgumentNullException

    asset is null -or- name is null or empty.

    Rename(InputAction, String)

    Rename an existing action.

    Declaration
    public static void Rename(this InputAction action, string newName)
    Parameters
    Type Name Description
    InputAction action

    Action to assign a new name to. Can be singleton action or action that is part of a map.

    String newName

    New name to assign to action. Cannot be empty.

    Remarks

    Renaming an action will also update the bindings that refer to the action.

    Exceptions
    Type Condition
    ArgumentNullException

    action is null or newName is null or empty.

    InvalidOperationException

    actionMap of action already contains an action called newName.

    WithBindingGroup(InputControlScheme, String)

    Declaration
    public static InputControlScheme WithBindingGroup(this InputControlScheme scheme, string bindingGroup)
    Parameters
    Type Name Description
    InputControlScheme scheme
    String bindingGroup
    Returns
    Type Description
    InputControlScheme

    WithOptionalDevice(InputControlScheme, String)

    Declaration
    public static InputControlScheme WithOptionalDevice(this InputControlScheme scheme, string controlPath)
    Parameters
    Type Name Description
    InputControlScheme scheme
    String controlPath
    Returns
    Type Description
    InputControlScheme

    WithRequiredDevice(InputControlScheme, String)

    Declaration
    public static InputControlScheme WithRequiredDevice(this InputControlScheme scheme, string controlPath)
    Parameters
    Type Name Description
    InputControlScheme scheme
    String controlPath
    Returns
    Type Description
    InputControlScheme
    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on 22 January 2021