docs.unity3d.com
    Show / Hide Table of Contents

    Class InputControl<TValue>

    Base class for input controls with a specific value type.

    Inheritance
    Object
    InputControl
    InputControl<TValue>
    AxisControl
    DoubleControl
    IntegerControl
    QuaternionControl
    TouchControl
    TouchPhaseControl
    Vector2Control
    Vector3Control
    BoneControl
    EyesControl
    PoseControl
    Inherited Members
    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.Item[String]
    InputControl.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.EvaluateMagnitude(Void*)
    InputControl.TryGetChildControl(String)
    InputControl.TryGetChildControl<TControl>(String)
    InputControl.GetChildControl(String)
    InputControl.GetChildControl<TControl>(String)
    InputControl.FinishSetup()
    InputControl.RefreshConfigurationIfNeeded()
    InputControl.RefreshConfiguration()
    InputControl.m_StateBlock
    InputControl.currentStatePtr
    InputControl.previousFrameStatePtr
    InputControl.defaultStatePtr
    InputControl.noiseMaskPtr
    InputControl.stateOffsetRelativeToDeviceRoot
    Namespace: UnityEngine.InputSystem
    Syntax
    public abstract class InputControl<TValue> : InputControl where TValue : struct
    Type Parameters
    Name Description
    TValue

    Type of value captured by the control. Note that this does not mean that the control has to store data in the given value format. A control that captures float values, for example, may be stored in state as byte values instead.

    Properties

    valueSizeInBytes

    Declaration
    public override int valueSizeInBytes { get; }
    Property Value
    Type Description
    Int32
    Overrides
    InputControl.valueSizeInBytes

    valueType

    Declaration
    public override Type valueType { get; }
    Property Value
    Type Description
    Type
    Overrides
    InputControl.valueType

    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
    InputControl.CompareValue(Void*, Void*)

    ProcessValue(TValue)

    Declaration
    public TValue ProcessValue(TValue value)
    Parameters
    Type Name Description
    TValue value
    Returns
    Type Description
    TValue

    ReadDefaultValue()

    Get the control's default value.

    Declaration
    public TValue ReadDefaultValue()
    Returns
    Type Description
    TValue

    The control's default value.

    Remarks

    This is not necessarily equivalent to default(TValue). A control's default value is determined by reading its value from the default state (defaultStatePtr) which in turn is determined from settings in the control's registered layout (defaultState).

    ReadUnprocessedValue()

    Declaration
    public TValue ReadUnprocessedValue()
    Returns
    Type Description
    TValue

    ReadUnprocessedValueFromState(Void*)

    Declaration
    public abstract TValue ReadUnprocessedValueFromState(void *statePtr)
    Parameters
    Type Name Description
    Void* statePtr
    Returns
    Type Description
    TValue

    ReadValue()

    Get the control's current value as read from currentStatePtr

    Declaration
    public TValue ReadValue()
    Returns
    Type Description
    TValue

    The control's current value.

    Remarks

    This can only be called on devices that have been added to the system (added).

    ReadValueFromBufferAsObject(Void*, Int32)

    Declaration
    public override object ReadValueFromBufferAsObject(void *buffer, int bufferSize)
    Parameters
    Type Name Description
    Void* buffer
    Int32 bufferSize
    Returns
    Type Description
    Object
    Overrides
    InputControl.ReadValueFromBufferAsObject(Void*, Int32)

    ReadValueFromPreviousFrame()

    Get the control's value from the previous frame (previousFrameStatePtr).

    Declaration
    public TValue ReadValueFromPreviousFrame()
    Returns
    Type Description
    TValue

    The control's value in the previous frame.

    ReadValueFromState(Void*)

    Declaration
    public TValue ReadValueFromState(void *statePtr)
    Parameters
    Type Name Description
    Void* statePtr
    Returns
    Type Description
    TValue

    ReadValueFromStateAsObject(Void*)

    Read the control's final, processed value from the given state and return the value as an object.

    Declaration
    public override object ReadValueFromStateAsObject(void *statePtr)
    Parameters
    Type Name Description
    Void* statePtr
    Returns
    Type Description
    Object

    The control's value as stored in statePtr.

    Overrides
    InputControl.ReadValueFromStateAsObject(Void*)
    Remarks

    This method allocates GC memory and should not be used during normal gameplay operation.

    See Also
    ReadValueFromStateIntoBuffer(Void*, Void*, Int32)

    ReadValueFromStateIntoBuffer(Void*, Void*, Int32)

    Read the control's final, processed value from the given state and store it in the given buffer.

    Declaration
    public override void ReadValueFromStateIntoBuffer(void *statePtr, void *bufferPtr, int bufferSize)
    Parameters
    Type Name Description
    Void* statePtr

    State to read the value for the control from.

    Void* bufferPtr

    Buffer to store the value in.

    Int32 bufferSize

    Size of bufferPtr in bytes. Must be at least valueSizeInBytes. If it is smaller, will be thrown.

    Overrides
    InputControl.ReadValueFromStateIntoBuffer(Void*, Void*, Int32)
    See Also
    ReadValueFromStateAsObject(Void*)
    WriteValueFromBufferIntoState(Void*, Int32, Void*)

    WriteValueFromBufferIntoState(Void*, Int32, Void*)

    Declaration
    public override void WriteValueFromBufferIntoState(void *bufferPtr, int bufferSize, void *statePtr)
    Parameters
    Type Name Description
    Void* bufferPtr
    Int32 bufferSize
    Void* statePtr
    Overrides
    InputControl.WriteValueFromBufferIntoState(Void*, Int32, Void*)

    WriteValueFromObjectIntoState(Object, Void*)

    Read a value object and store it as state in the given memory.

    Declaration
    public override void WriteValueFromObjectIntoState(object value, void *statePtr)
    Parameters
    Type Name Description
    Object value

    Value for the control.

    Void* statePtr

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

    Overrides
    InputControl.WriteValueFromObjectIntoState(Object, 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.

    See Also
    WriteValueFromBufferIntoState(Void*, Int32, Void*)

    WriteValueIntoState(TValue, Void*)

    Declaration
    public virtual void WriteValueIntoState(TValue value, void *statePtr)
    Parameters
    Type Name Description
    TValue value
    Void* statePtr

    Extension Methods

    InputControlExtensions.FindInParentChain<TControl>(InputControl)
    InputControlExtensions.IsPressed(InputControl, Single)
    InputControlExtensions.IsActuated(InputControl, Single)
    InputControlExtensions.ReadValueAsObject(InputControl)
    InputControlExtensions.ReadValueIntoBuffer(InputControl, Void*, Int32)
    InputControlExtensions.ReadDefaultValueAsObject(InputControl)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.ReadValueFromEventAsObject(InputControl, InputEventPtr)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.WriteValueFromObjectIntoEvent(InputControl, InputEventPtr, Object)
    InputControlExtensions.WriteValueIntoState(InputControl, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl, TValue, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, TValue, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, Void*)
    InputControlExtensions.WriteValueIntoState<TValue, TState>(InputControl<TValue>, TValue, ref TState)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl, TValue, InputEventPtr)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl<TValue>, TValue, InputEventPtr)
    InputControlExtensions.CheckStateIsAtDefault(InputControl)
    InputControlExtensions.CheckStateIsAtDefault(InputControl, Void*, Void*)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl, Void*)
    InputControlExtensions.CompareStateIgnoringNoise(InputControl, Void*)
    InputControlExtensions.CompareState(InputControl, Void*, Void*, Void*)
    InputControlExtensions.CompareState(InputControl, Void*, Void*)
    InputControlExtensions.HasValueChangeInState(InputControl, Void*)
    InputControlExtensions.HasValueChangeInEvent(InputControl, InputEventPtr)
    InputControlExtensions.GetStatePtrFromStateEvent(InputControl, InputEventPtr)
    InputControlExtensions.ResetToDefaultStateInEvent(InputControl, InputEventPtr)
    InputControlExtensions.QueueValueChange<TValue>(InputControl<TValue>, TValue, Double)
    InputControlExtensions.FindControlsRecursive<TControl>(InputControl, IList<TControl>, Func<TControl, Boolean>)
    In This Article
    • Properties
      • valueSizeInBytes
      • valueType
    • Methods
      • CompareValue(Void*, Void*)
      • ProcessValue(TValue)
      • ReadDefaultValue()
      • ReadUnprocessedValue()
      • ReadUnprocessedValueFromState(Void*)
      • ReadValue()
      • ReadValueFromBufferAsObject(Void*, Int32)
      • ReadValueFromPreviousFrame()
      • ReadValueFromState(Void*)
      • ReadValueFromStateAsObject(Void*)
      • ReadValueFromStateIntoBuffer(Void*, Void*, Int32)
      • WriteValueFromBufferIntoState(Void*, Int32, Void*)
      • WriteValueFromObjectIntoState(Object, Void*)
      • WriteValueIntoState(TValue, Void*)
    • Extension Methods
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023