docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct InputActionSetupExtensions.BindingSyntax

    Write accessor to a binding on either an InputAction or an InputActionMap.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Namespace: UnityEngine.InputSystem
    Assembly: Unity.InputSystem.dll
    Syntax
    public struct InputActionSetupExtensions.BindingSyntax
    Remarks

    Both bindings and bindings are read-only. To modify bindings (other than setting overrides which you can do through ApplyBindingOverride(InputAction, int, InputBinding)), it is necessary to gain indirect write access through this structure.

    playerInput.actions["fire"]
        .ChangeBinding(0)
        .WithPath("<Keyboard>/space");

    Properties

    binding

    The current binding in entirety.

    Declaration
    public InputBinding binding { get; }
    Property Value
    Type Description
    InputBinding
    Exceptions
    Type Condition
    InvalidOperationException

    The accessor is not valid.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    bindingIndex

    Index of the binding that the accessor refers to.

    Declaration
    public int bindingIndex { get; }
    Property Value
    Type Description
    int
    Remarks

    When accessing bindings on an InputAction, this is the index in bindings of the action. When accessing bindings on an InputActionMap, it is the index bindings of the map.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    valid

    True if the if binding accessor is valid.

    Declaration
    public bool valid { get; }
    Property Value
    Type Description
    bool
    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    Methods

    Erase()

    Remove the binding.

    Declaration
    public void Erase()
    Remarks

    If the binding is a composite (see isComposite), part bindings of the composite will be removed as well.

    Note that the accessor will not necessarily be invalidated. Instead, it will point to what used to be the next binding in the array (though that means the accessor will be invalid if the binding that got erased was the last one in the array).

    Exceptions
    Type Condition
    InvalidOperationException

    The instance is not valid.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    InsertPartBinding(string, string)

    Insert a composite part into a composite binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax InsertPartBinding(string partName, string path)
    Parameters
    Type Name Description
    string partName

    Name of the part in composite binding.

    string path

    Control path to bind to.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    ArgumentNullException

    Part name is null or empty.

    InvalidOperationException

    The binding accessor is invalid or the binding accessor is not pointing to composite or part binding.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    NextBinding()

    Switch to configuring the next binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax NextBinding()
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    An instance configured to edit the next binding or an invalid (see valid) instance if there is no next binding.

    Remarks

    If the BindingSyntax is restricted to a single action, the result will be invalid (see valid) if there is no next binding on the action. If the BindingSyntax is restricted to an InputActionMap, the result will be be invalid if there is no next binding in the map.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    NextCompositeBinding(string)

    Iterate to the next composite binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax NextCompositeBinding(string compositeName = null)
    Parameters
    Type Name Description
    string compositeName

    If null (default), an accessor to the next composite binding, regardless of name or type, is returned. If it is not null, can be either the name of the binding (see name) or the name of the composite used in the binding (see RegisterBindingComposite(Type, string)

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    A write accessor to the next composite binding or an invalid accessor (see valid) if no such binding was found.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    NextPartBinding(string)

    Iterate to the next part binding of the current composite with the given part name.

    Declaration
    public InputActionSetupExtensions.BindingSyntax NextPartBinding(string partName)
    Parameters
    Type Name Description
    string partName

    Name of the part of the binding, such as "Positive".

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    An accessor to the next part binding with the given name or an invalid (see valid) accessor if there is no such binding.

    Remarks

    Each binding that is part of a composite is marked with isPartOfComposite set to true. The name of the part is determined by name (comparison is case-insensitive). Which parts are relevant to a specific composite is determined by the type of composite. An AxisComposite, for example, has "Negative" and a "Positive" part.

    // Delete first "Positive" part of "Axis" composite.
    action.ChangeCompositeBinding("Axis")
        .NextPartBinding("Positive").Erase();
    Exceptions
    Type Condition
    ArgumentNullException

    partName is null or empty.

    See Also
    isPartOfComposite
    isComposite
    InputBindingComposite

    PreviousBinding()

    Switch to configuring the previous binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax PreviousBinding()
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    An instance configured to edit the previous binding or an invalid (see valid) instance if there is no previous binding.

    Remarks

    If the BindingSyntax is restricted to a single action, the result will be invalid (see valid) if there is no previous binding on the action. If the BindingSyntax is restricted to an InputActionMap, the result will be be invalid if there is no previous binding in the map.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    PreviousCompositeBinding(string)

    Iterate to the previous composite binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax PreviousCompositeBinding(string compositeName = null)
    Parameters
    Type Name Description
    string compositeName

    If null (default), an accessor to the previous composite binding, regardless of name or type, is returned. If it is not null, can be either the name of the binding (see name) or the name of the composite used in the binding (see RegisterBindingComposite(Type, string)).

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    A write accessor to the previous composite binding or an invalid accessor (see valid) if no such binding was found.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    PreviousPartBinding(string)

    Iterate to the previous part binding of the current composite with the given part name.

    Declaration
    public InputActionSetupExtensions.BindingSyntax PreviousPartBinding(string partName)
    Parameters
    Type Name Description
    string partName

    Name of the part of the binding, such as "Positive".

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    An accessor to the previous part binding with the given name or an invalid (see valid) accessor if there is no such binding.

    Remarks

    Each binding that is part of a composite is marked with isPartOfComposite set to true. The name of the part is determined by name (comparison is case-insensitive). Which parts are relevant to a specific composite is determined by the type of composite. An AxisComposite, for example, has "Negative" and a "Positive" part.

    Exceptions
    Type Condition
    ArgumentNullException

    partName is null or empty.

    See Also
    isPartOfComposite
    isComposite
    InputBindingComposite

    To(InputBinding)

    Replace the current binding with the given one.

    Declaration
    public InputActionSetupExtensions.BindingSyntax To(InputBinding binding)
    Parameters
    Type Name Description
    InputBinding binding

    An input binding.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Remarks

    This method replaces the current binding wholesale, i.e. it will overwrite all fields. Be aware that this has the potential of corrupting the binding data in case the given binding is a composite.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    Triggering(InputAction)

    Specify which action to trigger.

    Declaration
    public InputActionSetupExtensions.BindingSyntax Triggering(InputAction action)
    Parameters
    Type Name Description
    InputAction action

    Action to trigger.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    ArgumentNullException

    Provided action is null.

    ArgumentException

    Provided action is a singleton action (not part of any action maps).

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithGroup(string)

    Add group to the list of groups of the binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithGroup(string group)
    Parameters
    Type Name Description
    string group

    Name of the binding group (such as "Gamepad").

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    ArgumentException

    group is null or empty -or- it contains a Separator character.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithGroups(string)

    Add all the groups specified in groups to the list of groups of the binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithGroups(string groups)
    Parameters
    Type Name Description
    string groups

    A semi-colon separated list of group names.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithInteraction(string)

    Add an interaction via specified name in interaction to the list of interactions.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithInteraction(string interaction)
    Parameters
    Type Name Description
    string interaction

    Interaction class name

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    ArgumentException

    If interaction name is null or empty.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithInteraction<TInteraction>()

    Add an interaction of type specified in TInteraction to the list of interactions.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithInteraction<TInteraction>() where TInteraction : IInputInteraction
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Type Parameters
    Name Description
    TInteraction
    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    NotSupportedException

    Interaction type has not been registered.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithInteractions(string)

    Add the set of interactions specified in interactions to the list of interactions.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithInteractions(string interactions)
    Parameters
    Type Name Description
    string interactions

    A semi-colon separated list of interaction names.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithName(string)

    Set the name of the binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithName(string name)
    Parameters
    Type Name Description
    string name

    Name for the binding.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is not valid.

    See Also
    name

    WithPath(string)

    Set the path of the binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithPath(string path)
    Parameters
    Type Name Description
    string path

    Path for the binding.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is not valid.

    See Also
    path

    WithProcessor(string)

    Add a processor to the list of processors of the binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithProcessor(string processor)
    Parameters
    Type Name Description
    string processor

    Name of the processor, such as "Scale".

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    ArgumentException

    The processor name is null or empty.

    ArgumentException

    The processor name contains a semi-colon.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithProcessor<TProcessor>()

    Add a processor to the list of processors of the binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithProcessor<TProcessor>()
    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Type Parameters
    Name Description
    TProcessor

    Type of processor.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    NotSupportedException

    Processor type has not been registered.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    WithProcessors(string)

    Add processors to the list of processors of the binding.

    Declaration
    public InputActionSetupExtensions.BindingSyntax WithProcessors(string processors)
    Parameters
    Type Name Description
    string processors

    A semi-colon separated list of processor names.

    Returns
    Type Description
    InputActionSetupExtensions.BindingSyntax

    The same binding syntax for further configuration.

    Exceptions
    Type Condition
    InvalidOperationException

    The binding accessor is invalid.

    See Also
    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)

    See Also

    AddBinding(InputAction, InputBinding)
    ChangeBinding(InputAction, int)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)