Struct InputActionSetupExtensions.BindingSyntax
Write accessor to a binding on either an InputAction or an InputActionMap.
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
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
valid
True if the if binding accessor is valid.
Declaration
public bool valid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
See Also
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
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
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
NextCompositeBinding(string)
Iterate to the next composite binding.
Declaration
public InputActionSetupExtensions.BindingSyntax NextCompositeBinding(string compositeName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | compositeName | If |
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
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 |
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 |
|
See Also
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
PreviousCompositeBinding(string)
Iterate to the previous composite binding.
Declaration
public InputActionSetupExtensions.BindingSyntax PreviousCompositeBinding(string compositeName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | compositeName | If |
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
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 |
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 |
|
See Also
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
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
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 |
|
See Also
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
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
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
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
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
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
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
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
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. |