Class AxisControl
A floating-point axis control.
Inherited Members
Namespace: UnityEngine.InputSystem.Controls
Syntax
[Preserve]
public class AxisControl : InputControl<float>
Remarks
Can optionally be configured to perform normalization. Stored as either a float, a short, a byte, or a single bit.
Constructors
AxisControl()
Default-initialize the control.
Declaration
public AxisControl()
Remarks
Defaults the format to FormatFloat.
Fields
clamp
Clamping behavior when reading values. None by default.
Declaration
public AxisControl.Clamp clamp
Field Value
Type | Description |
---|---|
AxisControl.Clamp | Clamping behavior. |
Remarks
When a value is read from the control's state, it is first converted to a floating-point number.
See Also
clampConstant
When clamp is set to ToConstantBeforeNormalize and the value is outside of the range defined by clampMin and clampMax, this value is returned.
Declaration
public float clampConstant
Field Value
Type | Description |
---|---|
Single | Constant value to return when value is outside of clamping range. |
clampMax
Declaration
public float clampMax
Field Value
Type | Description |
---|---|
Single | Upper bound of clamping range. Inclusive. |
clampMin
Declaration
public float clampMin
Field Value
Type | Description |
---|---|
Single | Lower bound of clamping range. Inclusive. |
invert
If true, the input value will be inverted, i.e. multiplied by -1. Off by default.
Declaration
public bool invert
Field Value
Type | Description |
---|---|
Boolean | Whether to invert the input value. |
normalize
If true, normalize the input value to [0..1] or [-1..1] (depending on the value of normalizeZero. Off by default.
Declaration
public bool normalize
Field Value
Type | Description |
---|---|
Boolean | Whether to normalize input values or not. |
See Also
normalizeMax
If normalize is on, this is the input value that corresponds to 1 of the normalized [0..1] or [-1..1] range.
Declaration
public float normalizeMax
Field Value
Type | Description |
---|---|
Single | Input value that should become 1. |
Remarks
In other words, with normalize on, input values are mapped from the range of [normalizeMin..normalizeMax] to [0..1] or [-1..1] (depending on normalizeZero).
normalizeMin
If normalize is on, this is the input value that corresponds to 0 of the normalized [0..1] or [-1..1] range.
Declaration
public float normalizeMin
Field Value
Type | Description |
---|---|
Single | Input value that should become 0 or -1. |
Remarks
In other words, with normalize on, input values are mapped from the range of [normalizeMin..normalizeMax] to [0..1] or [-1..1] (depending on normalizeZero).
normalizeZero
Where to put the zero point of the normalization range. Only relevant if normalize is set to true. Defaults to 0.
Declaration
public float normalizeZero
Field Value
Type | Description |
---|---|
Single | Zero point of normalization range. |
Remarks
The value of this property determines where the zero point is located in the range established by normalizeMin and normalizeMax.
If normalizeZero
is placed at normalizeMin, the normalization
returns a value in the [0..1] range mapped from the input value range of
normalizeMin and normalizeMax.
If normalizeZero
is placed in-between normalizeMin and
normalizeMax, normalization returns a value in the [-1..1] mapped
from the input value range of normalizeMin and normalizeMax
and the zero point between the two established by normalizeZero
.
scale
Whether the scale the input value by scaleFactor. Off by default.
Declaration
public bool scale
Field Value
Type | Description |
---|---|
Boolean | True if inputs should be scaled by scaleFactor. |
scaleFactor
Value to multiple input values with. Only applied if scale is true
.
Declaration
public float scaleFactor
Field Value
Type | Description |
---|---|
Single | Multiplier for input values. |
Methods
CompareValue(Void*, Void*)
Declaration
public override bool CompareValue(void *firstStatePtr, void *secondStatePtr)
Parameters
Type | Name | Description |
---|---|---|
Void* | firstStatePtr | |
Void* | secondStatePtr |
Returns
Type | Description |
---|---|
Boolean |
Overrides
EvaluateMagnitude(Void*)
Compute an absolute, normalized magnitude value that indicates the extent to which the control is actuated in the given state.
Declaration
public override float EvaluateMagnitude(void *statePtr)
Parameters
Type | Name | Description |
---|---|---|
Void* | statePtr | State containing the control's stateBlock. |
Returns
Type | Description |
---|---|
Single | Amount of actuation of the control or -1 if it cannot be determined. |
Overrides
See Also
FinishSetup()
Declaration
protected override void FinishSetup()
Overrides
Preprocess(Single)
Apply modifications to the given value according to the parameters configured on the control (clamp, normalize, etc).
Declaration
protected float Preprocess(float value)
Parameters
Type | Name | Description |
---|---|---|
Single | value | Input value. |
Returns
Type | Description |
---|---|
Single | A processed value (clamped, normalized, etc). |
See Also
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 |