Class AxisControl
A floating-point axis control.
Inherited Members
Namespace: UnityEngine .InputSystem .Controls
Assembly: Unity.InputSystem.dll
Syntax
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 Format
Fields
clamp
Clamping behavior when reading values. None by default.
Declaration
public AxisControl.Clamp clamp
Field Value
Type | Description |
---|---|
Axis |
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 To
Declaration
public float clampConstant
Field Value
Type | Description |
---|---|
float | Constant value to return when value is outside of clamping range. |
clampMax
Declaration
public float clampMax
Field Value
Type | Description |
---|---|
float | Upper bound of clamping range. Inclusive. |
clampMin
Declaration
public float clampMin
Field Value
Type | Description |
---|---|
float | 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 |
---|---|
bool | Whether to invert the input value. |
normalize
If true, normalize the input value to [0..1] or [-1..1] (depending on the
value of normalize
Declaration
public bool normalize
Field Value
Type | Description |
---|---|
bool | 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 |
---|---|
float | 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
normalize
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 |
---|---|
float | 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
normalize
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 |
---|---|
float | Zero point of normalization range. |
Remarks
The value of this property determines where the zero point is located in the
range established by normalize
If normalizeZero
is placed at normalize
If normalizeZero
is placed in-between normalizenormalizeZero
.
scale
Whether the scale the input value by scale
Declaration
public bool scale
Field Value
Type | Description |
---|---|
bool | True if inputs should be scaled by scale |
scaleFactor
Value to multiple input values with. Only applied if scale is true
.
Declaration
public float scaleFactor
Field Value
Type | Description |
---|---|
float | Multiplier for input values. |
Methods
CalculateOptimizedControlDataType()
Calculates and returns a optimized data type that can represent a control's value in memory directly.
The value then is cached in optimized
Declaration
protected override FourCC CalculateOptimizedControlDataType()
Returns
Type | Description |
---|---|
Four |
Overrides
CompareValue(void*, void*)
Compare the value of the control as read from firstStatePtr
to that read from
secondStatePtr
and return true if they are equal.
Declaration
public override bool CompareValue(void* firstStatePtr, void* secondStatePtr)
Parameters
Type | Name | Description |
---|---|---|
void* | firstStatePtr | Memory containing the control's state |
void* | secondStatePtr | Memory containing the control's state |
Returns
Type | Description |
---|---|
bool | True if the value of the control is equal in both |
Overrides
Remarks
Unlike Compare
This method will apply epsilons (Epsilon) when comparing floats.
See Also
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 state |
Returns
Type | Description |
---|---|
float | Amount of actuation of the control or -1 if it cannot be determined. |
Overrides
See Also
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>
Preprocess(float)
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 |
---|---|---|
float | value | Input value. |
Returns
Type | Description |
---|---|
float | 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 |
---|---|
float |
Overrides
WriteValueIntoState(float, void*)
Declaration
public override void WriteValueIntoState(float value, void* statePtr)