docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AxisControl

    A floating-point axis control.

    Inheritance
    object
    InputControl
    InputControl<float>
    AxisControl
    ButtonControl
    DpadControl.DpadAxisControl
    Inherited Members
    InputControl<float>.valueType
    InputControl<float>.valueSizeInBytes
    InputControl<float>.value
    InputControl<float>.ReadValue()
    InputControl<float>.ReadValueFromPreviousFrame()
    InputControl<float>.ReadDefaultValue()
    InputControl<float>.ReadValueFromState(void*)
    InputControl<float>.ReadValueFromStateWithCaching(void*)
    InputControl<float>.ReadUnprocessedValueFromStateWithCaching(void*)
    InputControl<float>.ReadUnprocessedValue()
    InputControl<float>.ReadValueFromStateAsObject(void*)
    InputControl<float>.ReadValueFromStateIntoBuffer(void*, void*, int)
    InputControl<float>.WriteValueFromBufferIntoState(void*, int, void*)
    InputControl<float>.WriteValueFromObjectIntoState(object, void*)
    InputControl<float>.ReadValueFromBufferAsObject(void*, int)
    InputControl<float>.ProcessValue(float)
    InputControl<float>.ProcessValue(ref float)
    InputControl.name
    InputControl.displayName
    InputControl.shortDisplayName
    InputControl.path
    InputControl.layout
    InputControl.variants
    InputControl.device
    InputControl.parent
    InputControl.children
    InputControl.usages
    InputControl.aliases
    InputControl.stateBlock
    InputControl.noisy
    InputControl.synthetic
    InputControl.this[string]
    InputControl.magnitude
    InputControl.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.TryGetChildControl(string)
    InputControl.TryGetChildControl<TControl>(string)
    InputControl.GetChildControl(string)
    InputControl.GetChildControl<TControl>(string)
    InputControl.RefreshConfigurationIfNeeded()
    InputControl.RefreshConfiguration()
    InputControl.m_StateBlock
    InputControl.currentStatePtr
    InputControl.previousFrameStatePtr
    InputControl.defaultStatePtr
    InputControl.noiseMaskPtr
    InputControl.stateOffsetRelativeToDeviceRoot
    InputControl.optimizedControlDataType
    InputControl.ApplyParameterChanges()
    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 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
    clampMin
    clampMax
    clampConstant

    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
    float

    Constant value to return when value is outside of clamping range.

    clampMax

    Upper end of the clamping range when clamp is not None.

    Declaration
    public float clampMax
    Field Value
    Type Description
    float

    Upper bound of clamping range. Inclusive.

    clampMin

    Lower end of the clamping range when clamp is not None.

    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 normalizeZero. Off by default.

    Declaration
    public bool normalize
    Field Value
    Type Description
    bool

    Whether to normalize input values or not.

    See Also
    normalizeMin
    normalizeMax

    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 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
    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 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
    float

    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
    bool

    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
    float

    Multiplier for input values.

    Methods

    CalculateOptimizedControlDataType()

    Calculates and returns an optimized data type that can represent a control's value in memory directly.

    Declaration
    protected override FourCC CalculateOptimizedControlDataType()
    Returns
    Type Description
    FourCC

    An optimized data type that can represent a control's value in memory directly. InputStateBlock

    Overrides
    InputControl.CalculateOptimizedControlDataType()
    Remarks

    The value then is cached in optimizedControlDataType. This method is for internal use only, you should not call this from your own code.

    CompareValue(void*, void*)

    Compared values in state buffers.

    Declaration
    public override bool CompareValue(void* firstStatePtr, void* secondStatePtr)
    Parameters
    Type Name Description
    void* firstStatePtr

    The first state buffer to read value from.

    void* secondStatePtr

    The second state buffer to read value from.

    Returns
    Type Description
    bool

    True if the buffer values match. False if they differ.

    Overrides
    InputControl<float>.CompareValue(void*, void*)

    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
    float

    Amount of actuation of the control or -1 if it cannot be determined.

    Overrides
    InputControl.EvaluateMagnitude(void*)
    Remarks

    Magnitudes do not make sense for all types of controls. For example, for a control that represents an enumeration of values (such as TouchPhaseControl), there is no meaningful linear ordering of values (one could derive a linear ordering through the actual enum values but their assignment may be entirely arbitrary; it is unclear whether a state of Canceled has a higher or lower "magnitude" as a state of Began).

    Controls that have no meaningful magnitude will return -1 when calling this method. Any negative return value should be considered an invalid value.

    See Also
    EvaluateMagnitude()

    FinishSetup()

    Perform final initialization tasks after the control hierarchy has been put into place.

    Declaration
    protected override void FinishSetup()
    Overrides
    InputControl<float>.FinishSetup()
    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.

    Examples
      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");
                                }
                            }
    

    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
    clamp
    normalize
    scale
    invert

    ReadUnprocessedValueFromState(void*)

    Read value from provided statePtr.

    Declaration
    public override float ReadUnprocessedValueFromState(void* statePtr)
    Parameters
    Type Name Description
    void* statePtr

    State pointer to read from.

    Returns
    Type Description
    float

    The controls current value.

    Overrides
    InputControl<float>.ReadUnprocessedValueFromState(void*)
    Remarks

    Read value from provided statePtr without any caching.

    See Also
    value

    WriteValueIntoState(float, void*)

    Write a value into state at the given memory.

    Declaration
    public override void WriteValueIntoState(float value, void* statePtr)
    Parameters
    Type Name Description
    float value

    Value for the control to store in the state.

    void* statePtr

    State containing the control's stateBlock. Will receive the state as converted from the given value.

    Overrides
    InputControl<float>.WriteValueIntoState(float, void*)
    Remarks

    Writing values will NOT apply processors to the given value. This can mean that when reading a value from a control after it has been written to its state, the resulting value differs from what was written.

    Exceptions
    Type Condition
    NotSupportedException

    The control does not support writing. This is the case, for example, that compute values (such as the magnitude of a vector).

    See Also
    WriteValueFromBufferIntoState(void*, int, void*)

    Extension Methods

    InputControlExtensions.CheckStateIsAtDefault(InputControl)
    InputControlExtensions.CheckStateIsAtDefault(InputControl, void*, void*)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl, void*)
    InputControlExtensions.CompareState(InputControl, void*, void*)
    InputControlExtensions.CompareState(InputControl, void*, void*, void*)
    InputControlExtensions.CompareStateIgnoringNoise(InputControl, void*)
    InputControlExtensions.FindControlsRecursive<TControl>(InputControl, IList<TControl>, Func<TControl, bool>)
    InputControlExtensions.FindInParentChain<TControl>(InputControl)
    InputControlExtensions.GetStatePtrFromStateEvent(InputControl, InputEventPtr)
    InputControlExtensions.HasValueChangeInEvent(InputControl, InputEventPtr)
    InputControlExtensions.HasValueChangeInState(InputControl, void*)
    InputControlExtensions.IsActuated(InputControl, float)
    InputControlExtensions.IsPressed(InputControl, float)
    InputControlExtensions.ReadDefaultValueAsObject(InputControl)
    InputControlExtensions.ReadValueAsObject(InputControl)
    InputControlExtensions.ReadValueFromEventAsObject(InputControl, InputEventPtr)
    InputControlExtensions.ReadValueIntoBuffer(InputControl, void*, int)
    InputControlExtensions.ResetToDefaultStateInEvent(InputControl, InputEventPtr)
    InputControlExtensions.WriteValueFromObjectIntoEvent(InputControl, InputEventPtr, object)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl, TValue, InputEventPtr)
    InputControlExtensions.WriteValueIntoState(InputControl, void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl, TValue, void*)
    InputControlExtensions.AccumulateValueInEvent(InputControl<float>, void*, InputEventPtr)
    InputControlExtensions.QueueValueChange<TValue>(InputControl<TValue>, TValue, double)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl<TValue>, TValue, InputEventPtr)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, TValue, void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, void*)
    InputControlExtensions.WriteValueIntoState<TValue, TState>(InputControl<TValue>, TValue, ref TState)
    In This Article
    • Constructors
      • AxisControl()
    • Fields
      • clamp
      • clampConstant
      • clampMax
      • clampMin
      • invert
      • normalize
      • normalizeMax
      • normalizeMin
      • normalizeZero
      • scale
      • scaleFactor
    • Methods
      • CalculateOptimizedControlDataType()
      • CompareValue(void*, void*)
      • EvaluateMagnitude(void*)
      • FinishSetup()
      • Preprocess(float)
      • ReadUnprocessedValueFromState(void*)
      • WriteValueIntoState(float, void*)
    • Extension Methods
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)