Class DpadControl
A control made up of four discrete, directional buttons. Forms a vector but can also be addressed as individual buttons.
Inherited Members
Namespace: UnityEngine.InputSystem.Controls
Assembly: Unity.InputSystem.dll
Syntax
public class DpadControl : Vector2Control
Remarks
Is stored as four bits by default.
The vector that is aggregated from the button states is normalized. I.e.
even if pressing diagonally, the vector will have a length of 1 (instead
of reading something like (1,1)
for example).
Constructors
DpadControl()
Declaration
public DpadControl()
Properties
down
The button representing the vertical downwards state of the D-Pad.
Declaration
public ButtonControl down { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl |
left
The button representing the horizontal left state of the D-Pad.
Declaration
public ButtonControl left { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl |
right
The button representing the horizontal right state of the D-Pad.
Declaration
public ButtonControl right { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl |
up
Declaration
public ButtonControl up { get; set; }
Property Value
Type | Description |
---|---|
ButtonControl |
Methods
FinishSetup()
Perform final initialization tasks after the control hierarchy has been put into place.
Declaration
protected override void FinishSetup()
Overrides
Remarks
This method can be overridden to perform control- or device-specific setup work. The most common use case is for looking up child controls and storing them in local getters.
public class MyDevice : InputDevice
{
public ButtonControl button { get; private set; }
public AxisControl axis { get; private set; }
protected override void OnFinishSetup()
{
// Cache controls in getters.
button = GetChildControl("button");
axis = GetChildControl("axis");
}
}</code></pre></example>
MakeDpadVector(bool, bool, bool, bool, bool)
Create a direction vector from the given four button states.
Declaration
public static Vector2 MakeDpadVector(bool up, bool down, bool left, bool right, bool normalize = true)
Parameters
Type | Name | Description |
---|---|---|
bool | up | Whether button representing the up direction is pressed. |
bool | down | Whether button representing the down direction is pressed. |
bool | left | Whether button representing the left direction is pressed. |
bool | right | Whether button representing the right direction is pressed. |
bool | normalize | Whether to normalize the resulting vector. If this is false, vectors in the diagonal directions will have a magnitude of greater than 1. For example, up-left will be (-1,1). |
Returns
Type | Description |
---|---|
Vector2 | A 2D direction vector. |
MakeDpadVector(float, float, float, float)
Create a direction vector from the given axis states.
Declaration
public static Vector2 MakeDpadVector(float up, float down, float left, float right)
Parameters
Type | Name | Description |
---|---|---|
float | up | Axis value representing the up direction. |
float | down | Axis value representing the down direction. |
float | left | Axis value representing the left direction. |
float | right | Axis value representing the right direction. |
Returns
Type | Description |
---|---|
Vector2 | A 2D direction vector. |
ReadUnprocessedValueFromState(void*)
Declaration
public override Vector2 ReadUnprocessedValueFromState(void* statePtr)
Parameters
Type | Name | Description |
---|---|---|
void* | statePtr |
Returns
Type | Description |
---|---|
Vector2 |
Overrides
WriteValueIntoState(Vector2, void*)
Declaration
public override void WriteValueIntoState(Vector2 value, void* statePtr)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | |
void* | statePtr |