Struct InputBinding
A mapping of control input to an action.
Namespace: UnityEngine.InputSystem
Syntax
[Serializable]
public struct InputBinding : IEquatable<InputBinding>
Remarks
Each binding represents a value received from controls (see InputControl). There are two main types of bindings: "normal" bindings and "composite" bindings.
Normal bindings directly bind to control(s) by means of path which is a "control path" (see InputControlPath for details about how to form paths). At runtime, the path of such a binding may match none, one, or multiple controls. Each control matched by the path will feed input into the binding.
Composite bindings do not bind to controls themselves. Instead, they receive their input from their "part" bindings and then return a value representing a "composition" of those inputs. What composition specifically is performed depends on the type of the composite. AxisComposite, for example, will return a floating-point axis value computed from the state of two buttons.
The action that is triggered by a binding is determined by its action property. The resolution to an InputAction depends on where the binding is used. For example, bindings that are part of bindings will resolve action names to actions in the same InputActionMap.
A binding can also be used as a override specification. In that scenario, path, action, and groups become search criteria that can be used to find existing bindings, and overridePath becomes the path to override existing binding paths with.
Finally, a binding can be used as a form of specifying a mask that matching bindings must comply to. For example, a binding that has only groups set to "Gamepad" and all other fields set to default can be used to mask for bindings in the "Gamepad" group.
Fields
Separator
Declaration
public const char Separator = ';'
Field Value
Type | Description |
---|---|
System.Char |
Properties
action
Name or ID of the action triggered by the binding.
Declaration
public string action { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This is null if the binding does not trigger an action.
For InputBindings that are used as filters, this can be a "mapName/actionName" combination or "mapName/*" to match all actions in the given map.
See Also
effectiveInteractions
This is the interaction config which is effectively being used.
Declaration
public string effectiveInteractions { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This is either overrideInteractions if that is set, or interactions otherwise.
effectivePath
This is the bindings path which is effectively being used.
Declaration
public string effectivePath { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This is either overridePath if that is set, or path otherwise.
effectiveProcessors
This is the processor config which is effectively being used.
Declaration
public string effectiveProcessors { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This is either overrideProcessors if that is set, or processors otherwise.
groups
Declaration
public string groups { get; set; }
Property Value
Type | Description |
---|---|
System.String |
id
Declaration
public Guid id { get; set; }
Property Value
Type | Description |
---|---|
System.Guid |
interactions
Optional list of interactions and their parameters.
Declaration
public string interactions { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Examples
"tap,slowTap(duration=1.2)"
isComposite
Declaration
public bool isComposite { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
isPartOfComposite
Declaration
public bool isPartOfComposite { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
name
Optional name for the binding.
Declaration
public string name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
For bindings that isPartOfComposite, this is the name of the field on the binding composite object that should be initialized with the control target of the binding.
overrideInteractions
Declaration
public string overrideInteractions { get; set; }
Property Value
Type | Description |
---|---|
System.String |
overridePath
If the binding is overridden, this is the overriding path. Otherwise it is null.
Declaration
public string overridePath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
Not serialized as overrides are considered temporary, runtime-only state.
overrideProcessors
Declaration
public string overrideProcessors { get; set; }
Property Value
Type | Description |
---|---|
System.String |
path
Control path being bound to.
Declaration
public string path { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
If the binding is a composite (isComposite), the path is the composite string instead.
Examples
"/*/{PrimaryAction}"
processors
Optional list of processors to apply to control values.
Declaration
public string processors { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This list has the same format as processors.
Methods
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Equals(InputBinding)
Declaration
public bool Equals(InputBinding other)
Parameters
Type | Name | Description |
---|---|---|
InputBinding | other |
Returns
Type | Description |
---|---|
System.Boolean |
GenerateId()
Declaration
public void GenerateId()
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
MaskByGroup(String)
Declaration
public static InputBinding MaskByGroup(string group)
Parameters
Type | Name | Description |
---|---|---|
System.String | group |
Returns
Type | Description |
---|---|
InputBinding |
MaskByGroups(String[])
Declaration
public static InputBinding MaskByGroups(params string[] groups)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | groups |
Returns
Type | Description |
---|---|
InputBinding |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Operators
Equality(InputBinding, InputBinding)
Declaration
public static bool operator ==(InputBinding left, InputBinding right)
Parameters
Type | Name | Description |
---|---|---|
InputBinding | left | |
InputBinding | right |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(InputBinding, InputBinding)
Declaration
public static bool operator !=(InputBinding left, InputBinding right)
Parameters
Type | Name | Description |
---|---|---|
InputBinding | left | |
InputBinding | right |
Returns
Type | Description |
---|---|
System.Boolean |