Class Vector2Composite
A 2D planar motion vector computed from an up+down button pair and a left+right button pair.
Inherited Members
Namespace: UnityEngine.InputSystem.Composites
Syntax
public class Vector2Composite : InputBindingComposite<Vector2>
Remarks
This composite allows to grab arbitrary buttons from a device and arrange them in a D-Pad like configuration. Based on button presses, the composite will return a normalized direction vector (normalization can be turned off via normalize).
Opposing motions cancel each other out. Meaning that if, for example, both the left and right horizontal button are pressed, the resulting horizontal movement value will be zero.
Fields
down
Binding for the button that down (i.e. (0,-1)
) direction of the vector.
Declaration
public int down
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
This property is automatically assigned by the input system.
left
Binding for the button that left (i.e. (-1,0)
) direction of the vector.
Declaration
public int left
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
This property is automatically assigned by the input system.
normalize
If true (default), then the resulting vector will be normalized. Otherwise, diagonal
vectors will have a magnitude > 1 (i.e. will be new Vector2(1,1)
, for example,
instead of new Vector2(1,1).normalized
).
Declaration
public bool normalize
Field Value
Type | Description |
---|---|
System.Boolean |
right
Binding for the button that right (i.e. (1,0)
) direction of the vector.
Declaration
public int right
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
This property is automatically assigned by the input system.
up
Binding for the button that up (i.e. (0,1)
) direction of the vector.
Declaration
public int up
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
This property is automatically assigned by the input system.
Methods
EvaluateMagnitude(ref InputBindingCompositeContext)
Declaration
public override float EvaluateMagnitude(ref InputBindingCompositeContext context)
Parameters
Type | Name | Description |
---|---|---|
InputBindingCompositeContext | context |
Returns
Type | Description |
---|---|
System.Single |
Overrides
ReadValue(ref InputBindingCompositeContext)
Declaration
public override Vector2 ReadValue(ref InputBindingCompositeContext context)
Parameters
Type | Name | Description |
---|---|---|
InputBindingCompositeContext | context |
Returns
Type | Description |
---|---|
Vector2 |