Class DiscreteButtonControl
A button that is considered pressed if the underlying state has a value in the specific range.
Inheritance
Inherited Members
Namespace: UnityEngine.InputSystem.Controls
Syntax
[Preserve]
public class DiscreteButtonControl : ButtonControl
Remarks
This control is most useful for handling HID-style hat switches. Unlike DpadControl, which by default is stored as a bitfield of four bits that each represent a direction on the pad, these hat switches enumerate the possible directions that the switch can be moved in. For example, the value 1 could indicate that the switch is moved to the left whereas 3 could indicate it is moved up.
Fields
maxValue
Value (inclusive) beyond which to stop considering the button to be pressed.
Declaration
public int maxValue
Field Value
Type | Description |
---|---|
Int32 |
minValue
Value (inclusive) at which to start considering the button to be pressed.
Declaration
public int minValue
Field Value
Type | Description |
---|---|
Int32 |
Remarks
minValue is allowed to be larger than maxValue. This indicates a setup where the value wraps around beyond minValue, skips nullValue, and then goes all the way up to maxValue.
For example, if the underlying state represents a circular D-pad and enumerates its 9 possible positions (including null state) going clock-wise from 0 to 8 and with 1 indicating that the D-pad is pressed to the left, then 1, 2, and 8 would indicate that the "left" button is held on the D-pad. To set this up, set minValue to 8, maxValue to 2, and nullValue to 0 (the default).
nullValue
Declaration
public int nullValue
Field Value
Type | Description |
---|---|
Int32 |
wrapAtValue
Declaration
public int wrapAtValue
Field Value
Type | Description |
---|---|
Int32 |
Methods
FinishSetup()
Declaration
protected override void FinishSetup()
Overrides
ReadUnprocessedValueFromState(Void*)
Declaration
public override float ReadUnprocessedValueFromState(void *statePtr)
Parameters
Type | Name | Description |
---|---|---|
Void* | statePtr |
Returns
Type | Description |
---|---|
Single |
Overrides
WriteValueIntoState(Single, Void*)
Declaration
public override void WriteValueIntoState(float value, void *statePtr)
Parameters
Type | Name | Description |
---|---|---|
Single | value | |
Void* | statePtr |