Class ButtonControl
An axis that has a trigger point beyond which it is considered to be pressed.
Inherited Members
Namespace: UnityEngine.InputSystem.Controls
Syntax
public class ButtonControl : AxisControl
Remarks
By default stored as a single bit. In that format, buttons will only yield 0 and 1 as values. However, buttons return are AxisControls and yield full floating-point values and may thus have a range of values. See pressPoint for how button presses on such buttons are handled.
Constructors
ButtonControl()
Default-initialize the control.
Declaration
public ButtonControl()
Remarks
The default format for the control is FormatBit. The control's minimum value is set to 0 and the maximum value to 1.
Fields
pressPoint
The minimum value the button has to reach for it to be considered pressed.
Declaration
public float pressPoint
Field Value
Type | Description |
---|---|
Single | Button press threshold. |
Remarks
The button is considered pressed, if it has a value equal to or greater than this value.
By default, this property is set to -1. If the value of the property is negative, defaultButtonPressPoint is used.
The value can be configured as a parameter in a layout.
public class MyDevice : InputDevice
{
[InputControl(parameters = "pressPoint=0.234")]
public ButtonControl button { get; private set; }
//...
}
See Also
Properties
isPressed
Whether the button is currently pressed.
Declaration
public bool isPressed { get; }
Property Value
Type | Description |
---|---|
Boolean | True if button is currently pressed. |
Remarks
A button is considered press if it's value is equal to or greater than its button press threshold (pressPointOrDefault).
See Also
pressPointOrDefault
Return pressPoint if set, otherwise return defaultButtonPressPoint.
Declaration
public float pressPointOrDefault { get; }
Property Value
Type | Description |
---|---|
Single | Effective value to use for press point thresholds. |
See Also
wasPressedThisFrame
Declaration
public bool wasPressedThisFrame { get; }
Property Value
Type | Description |
---|---|
Boolean |
wasReleasedThisFrame
Declaration
public bool wasReleasedThisFrame { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
IsValueConsideredPressed(Single)
Whether the given value would be considered pressed for this button.
Declaration
public bool IsValueConsideredPressed(float value)
Parameters
Type | Name | Description |
---|---|---|
Single | value | Value for the button. |
Returns
Type | Description |
---|---|
Boolean | True if |