Class InputBindingComposite
A binding that synthesizes a value from from several component bindings.
Namespace: UnityEngine.InputSystem
Syntax
[Preserve]
public abstract class InputBindingComposite
Remarks
This is the base class for composite bindings. See InputBindingComposite<TValue> for more details about composites and for how to define custom composites.
Properties
valueSizeInBytes
Size of a value read by ReadValue(ref InputBindingCompositeContext, Void*, Int32).
Declaration
public abstract int valueSizeInBytes { get; }
Property Value
Type | Description |
---|---|
Int32 | Size of values stored in memory buffers by ReadValue(ref InputBindingCompositeContext, Void*, Int32). |
Remarks
This is usually implicitly defined by the size of values derived
from the type argument to InputBindingComposite<TValue>. E.g.
if the type argument is Vector2
, this property will be 8.
See Also
valueType
The type of value returned by the composite.
Declaration
public abstract Type valueType { get; }
Property Value
Type | Description |
---|---|
Type | Type of value returned by the composite. |
Remarks
Just like each InputControl has a specific type of value it will return, each composite has a specific type of value it will return. This is usually implicitly defined by the type parameter of InputBindingComposite<TValue>.
See Also
Methods
EvaluateMagnitude(ref InputBindingCompositeContext)
Determine the current level of actuation of the composite.
Declaration
public virtual float EvaluateMagnitude(ref InputBindingCompositeContext context)
Parameters
Type | Name | Description |
---|---|---|
InputBindingCompositeContext | context | Callback context for the binding composite. Use this to access the values supplied by part bindings. |
Returns
Type | Description |
---|---|
Single |
Remarks
This method by default returns -1, meaning that the composite does not support magnitudes. You can override the method to add support for magnitudes.
See EvaluateMagnitude() for details of how magnitudes work.
See Also
GetExpectedControlLayoutName(String, String)
Return the name of the control layout that is expected for the given part (e.g. "Up") on the given composite (e.g. "Dpad").
Declaration
public static string GetExpectedControlLayoutName(string composite, string part)
Parameters
Type | Name | Description |
---|---|---|
String | composite | Registration name of the composite. |
String | part | Name of the part. |
Returns
Type | Description |
---|---|
String | The layout name (such as "Button") expected for the given part on the composite or null if there is no composite with the given name or no part on the composite with the given name. |
Remarks
Expected control layouts can be set on composite parts by setting the layout property on them.
Examples
InputBindingComposite.GetExpectedControlLayoutName("Dpad", "Up") // Returns "Button"
// This is how Dpad communicates that:
[InputControl(layout = "Button")] public int up;
ReadValue(ref InputBindingCompositeContext, Void*, Int32)
Read a value from the composite without having to know the value type (unlike
Declaration
public abstract void ReadValue(ref InputBindingCompositeContext context, void *buffer, int bufferSize)
Parameters
Type | Name | Description |
---|---|---|
InputBindingCompositeContext | context | Callback context for the binding composite. Use this to access the values supplied by part bindings. |
Void* | buffer | Buffer that receives the value read for the composite. |
Int32 | bufferSize | Size of the buffer allocated at |
Remarks
This API will be used if someone calls ReadValue(Void*, Int32) with the action leading to the composite.
By deriving from InputBindingComposite<TValue>, this will automatically be implemented for you.
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
See Also
ReadValueAsObject(ref InputBindingCompositeContext)
Read the value of the composite as a boxed object. This allows reading the value without having to know the value type and without having to deal with raw byte buffers.
Declaration
public abstract object ReadValueAsObject(ref InputBindingCompositeContext context)
Parameters
Type | Name | Description |
---|---|---|
InputBindingCompositeContext | context | Callback context for the binding composite. Use this to access the values supplied by part bindings. |
Returns
Type | Description |
---|---|
Object | The current value of the composite according to the state passed in through
|
Remarks
This API will be used if someone calls ReadValueAsObject() with the action leading to the composite.
By deriving from InputBindingComposite<TValue>, this will automatically be implemented for you.