Struct InputActionSetupExtensions.BindingSyntax
Write accessor to a binding on either an InputAction or an InputActionMap.
Namespace: UnityEngine.InputSystem
Syntax
public struct BindingSyntax
Remarks
Both bindings and bindings are read-only. To modify bindings (other than setting overrides which you can do through ApplyBindingOverride(InputAction, Int32, 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 readonly InputBinding binding { get; }
Property Value
| Type | Description |
|---|---|
| InputBinding |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The accessor is not valid. |
bindingIndex
Index of the binding that the accessor refers to.
Declaration
public readonly int bindingIndex { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
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.
valid
True if the if binding accessor is valid.
Declaration
public readonly bool valid { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
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. |
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. |
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.
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. |
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.
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. |
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.
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). |
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 |
|
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. |
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. |
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. |
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. |
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. |
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. |
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. |