Struct InputControlScheme
A named set of zero or more device requirements along an associated binding group.
Namespace: UnityEngine.InputSystem
Syntax
[Serializable]
public struct InputControlScheme : IEquatable<InputControlScheme>
Remarks
Control schemes provide an additional layer on top of binding groups. While binding groups allow differentiating sets of bindings (e.g. a "Keyboard&Mouse" group versus a "Gamepad" group), control schemes impose a set of devices requirements that must be met in order for a specific set of bindings to be usable.
Constructors
InputControlScheme(String, String, IEnumerable<InputControlScheme.DeviceRequirement>)
Declaration
public InputControlScheme(string name, string basedOn = null, IEnumerable<InputControlScheme.DeviceRequirement> devices = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | |
System.String | basedOn | |
System.Collections.Generic.IEnumerable<InputControlScheme.DeviceRequirement> | devices |
Properties
baseScheme
Name of control scheme that this scheme is based on.
Declaration
public string baseScheme { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
When the control scheme is enabled, all bindings from the base control scheme will also be enabled. At the same time, bindings act as overrides on bindings coming through from the base scheme.
bindingGroup
Binding group that is associated with the control scheme.
Declaration
public string bindingGroup { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
All bindings in this group as well as in groups inherited from base control schemes are considered to be part of the control scheme.
deviceRequirements
Devices used by the control scheme.
Declaration
public ReadOnlyArray<InputControlScheme.DeviceRequirement> deviceRequirements { get; }
Property Value
Type | Description |
---|---|
ReadOnlyArray<InputControlScheme.DeviceRequirement> |
Remarks
No two entries will be allowed to match the same control or device at runtime in order for the requirements of the control scheme to be considered satisfied. If, for example, one entry requires a "<Gamepad>" and another entry requires a "<Gamepad>", then at runtime two gamepads will be required even though a single one will match both requirements individually. However, if, for example, one entry requires "<Gamepad>/leftStick" and another requires "<Gamepad>, the same device can match both requirements as each one resolves to a different control.
name
Name of the control scheme.
Declaration
public string name { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
May be empty or null except if the control scheme is part of an InputActionAsset.
See Also
Methods
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Equals(InputControlScheme)
Declaration
public bool Equals(InputControlScheme other)
Parameters
Type | Name | Description |
---|---|---|
InputControlScheme | other |
Returns
Type | Description |
---|---|
System.Boolean |
FindControlSchemeForDevice<TList>(InputDevice, TList)
Declaration
public static InputControlScheme? FindControlSchemeForDevice<TList>(InputDevice device, TList schemes)
where TList : IEnumerable<InputControlScheme>
Parameters
Type | Name | Description |
---|---|---|
InputDevice | device | |
TList | schemes |
Returns
Type | Description |
---|---|
System.Nullable<InputControlScheme> |
Type Parameters
Name | Description |
---|---|
TList |
FromJson(String)
Declaration
public static InputControlScheme FromJson(string json)
Parameters
Type | Name | Description |
---|---|---|
System.String | json |
Returns
Type | Description |
---|---|
InputControlScheme |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
PickDevicesFrom<TDevices>(TDevices)
Based on a list of devices, make a selection that matches the deviceRequirements imposed by the control scheme.
Declaration
public InputControlScheme.MatchResult PickDevicesFrom<TDevices>(TDevices devices)
where TDevices : IReadOnlyList<InputDevice>
Parameters
Type | Name | Description |
---|---|---|
TDevices | devices | A list of devices to choose from. |
Returns
Type | Description |
---|---|
InputControlScheme.MatchResult | A InputControlScheme.MatchResult structure containing the result of the pick. Note that this structure must be manually Dispose() or unmanaged memory will be leaked. |
Type Parameters
Name | Description |
---|---|
TDevices |
Remarks
Does not allocate managed memory.
SupportsDevice(InputDevice)
Declaration
public bool SupportsDevice(InputDevice device)
Parameters
Type | Name | Description |
---|---|---|
InputDevice | device |
Returns
Type | Description |
---|---|
System.Boolean |
ToJson()
Declaration
public string ToJson()
Returns
Type | Description |
---|---|
System.String |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Operators
Equality(InputControlScheme, InputControlScheme)
Declaration
public static bool operator ==(InputControlScheme left, InputControlScheme right)
Parameters
Type | Name | Description |
---|---|---|
InputControlScheme | left | |
InputControlScheme | right |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(InputControlScheme, InputControlScheme)
Declaration
public static bool operator !=(InputControlScheme left, InputControlScheme right)
Parameters
Type | Name | Description |
---|---|---|
InputControlScheme | left | |
InputControlScheme | right |
Returns
Type | Description |
---|---|
System.Boolean |