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 |
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).
InsertPartBinding(String, String)
Declaration
public InputActionSetupExtensions.BindingSyntax InsertPartBinding(string partName, string path)
Parameters
Type | Name | Description |
---|---|---|
String | partName | |
String | path |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
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. |
Remarks
var accessor = playerInput.actions["fire"].ChangeCompositeBinding("WASD")
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();
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)
Declaration
public InputActionSetupExtensions.BindingSyntax PreviousCompositeBinding(string compositeName = null)
Parameters
Type | Name | Description |
---|---|---|
String | compositeName |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
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.
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)
Declaration
public InputActionSetupExtensions.BindingSyntax Triggering(InputAction action)
Parameters
Type | Name | Description |
---|---|---|
InputAction | action |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
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. |
WithGroups(String)
Declaration
public InputActionSetupExtensions.BindingSyntax WithGroups(string groups)
Parameters
Type | Name | Description |
---|---|---|
String | groups |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
WithInteraction(String)
Declaration
public InputActionSetupExtensions.BindingSyntax WithInteraction(string interaction)
Parameters
Type | Name | Description |
---|---|---|
String | interaction |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
WithInteraction<TInteraction>()
Declaration
public InputActionSetupExtensions.BindingSyntax WithInteraction<TInteraction>()
where TInteraction : IInputInteraction
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
Type Parameters
Name | Description |
---|---|
TInteraction |
WithInteractions(String)
Declaration
public InputActionSetupExtensions.BindingSyntax WithInteractions(string interactions)
Parameters
Type | Name | Description |
---|---|---|
String | interactions |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
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. |
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. |
See Also
WithProcessor(String)
Declaration
public InputActionSetupExtensions.BindingSyntax WithProcessor(string processor)
Parameters
Type | Name | Description |
---|---|---|
String | processor |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
WithProcessor<TProcessor>()
Declaration
public InputActionSetupExtensions.BindingSyntax WithProcessor<TProcessor>()
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |
Type Parameters
Name | Description |
---|---|
TProcessor |
WithProcessors(String)
Declaration
public InputActionSetupExtensions.BindingSyntax WithProcessors(string processors)
Parameters
Type | Name | Description |
---|---|---|
String | processors |
Returns
Type | Description |
---|---|
InputActionSetupExtensions.BindingSyntax |