docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XRInputDeviceValueReader<TValue>

    A ScriptableObject that provides a typed value from a device from the XR input subsystem as defined by its characteristics and feature usage string. Intended to be used with an XRInputValueReader as its object reference or as part of an XRInputDeviceButtonReader.

    Inheritance
    object
    Object
    ScriptableObject
    XRInputDeviceValueReader
    XRInputDeviceValueReader<TValue>
    XRInputDeviceBoolValueReader
    XRInputDeviceFloatValueReader
    XRInputDeviceInputTrackingStateValueReader
    XRInputDeviceQuaternionValueReader
    XRInputDeviceVector2ValueReader
    XRInputDeviceVector3ValueReader
    Implements
    IXRInputValueReader<TValue>
    IXRInputValueReader
    Inherited Members
    XRInputDeviceValueReader.characteristics
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.Interaction.Toolkit.Inputs.Readers
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    public abstract class XRInputDeviceValueReader<TValue> : XRInputDeviceValueReader, IXRInputValueReader<TValue>, IXRInputValueReader where TValue : struct
    Type Parameters
    Name Description
    TValue

    Type of the value to read, such as Vector2 or float.

    Properties

    usage

    The name of the input feature usage to read.

    Declaration
    public InputFeatureUsageString<TValue> usage { get; set; }
    Property Value
    Type Description
    InputFeatureUsageString<TValue>

    Methods

    ReadBoolValue()

    Read the value of the input as a bool.

    Declaration
    protected bool ReadBoolValue()
    Returns
    Type Description
    bool

    Returns the value of the input as a bool.

    ReadFloatValue()

    Read the value of the input as a float.

    Declaration
    protected float ReadFloatValue()
    Returns
    Type Description
    float

    Returns the value of the input as a float.

    ReadInputTrackingStateValue()

    Read the value of the input as an InputTrackingState.

    Declaration
    protected InputTrackingState ReadInputTrackingStateValue()
    Returns
    Type Description
    InputTrackingState

    Returns the value of the input as a InputTrackingState.

    ReadQuaternionValue()

    Read the value of the input as a Quaternion.

    Declaration
    protected Quaternion ReadQuaternionValue()
    Returns
    Type Description
    Quaternion

    Returns the value of the input as a Quaternion.

    ReadUIntValue()

    Read the value of the input as an uint.

    Declaration
    protected uint ReadUIntValue()
    Returns
    Type Description
    uint

    Returns the value of the input as a uint.

    ReadValue()

    Read the current value from the input source.

    Declaration
    public abstract TValue ReadValue()
    Returns
    Type Description
    TValue

    Returns the current value from the input source. May return default(TValue) if unused or no source is set.

    ReadVector2Value()

    Read the value of the input as a Vector2.

    Declaration
    protected Vector2 ReadVector2Value()
    Returns
    Type Description
    Vector2

    Returns the value of the input as a Vector2.

    ReadVector3Value()

    Read the value of the input as a Vector3.

    Declaration
    protected Vector3 ReadVector3Value()
    Returns
    Type Description
    Vector3

    Returns the value of the input as a Vector3.

    RefreshInputDeviceIfNeeded()

    Updates the found input device used to read input from if it isn't valid. This should be called before attempting to read a value from the input device.

    Declaration
    protected bool RefreshInputDeviceIfNeeded()
    Returns
    Type Description
    bool

    Returns true if the input device is valid or if a valid one with matching characteristics was found.

    TryReadBoolValue(out bool)

    Try to read the value of the input as a bool.

    Declaration
    protected bool TryReadBoolValue(out bool value)
    Parameters
    Type Name Description
    bool value

    When this method returns true, the value read. Otherwise, the default for the type.

    Returns
    Type Description
    bool

    Returns true if the value was successfully read.

    TryReadFloatValue(out float)

    Try to read the value of the input as a float.

    Declaration
    protected bool TryReadFloatValue(out float value)
    Parameters
    Type Name Description
    float value

    When this method returns true, the value read. Otherwise, the default for the type.

    Returns
    Type Description
    bool

    Returns true if the value was successfully read.

    TryReadInputTrackingStateValue(out InputTrackingState)

    Try to read the value of the input as an InputTrackingState.

    Declaration
    protected bool TryReadInputTrackingStateValue(out InputTrackingState value)
    Parameters
    Type Name Description
    InputTrackingState value

    When this method returns true, the value read. Otherwise, the default for the type.

    Returns
    Type Description
    bool

    Returns true if the value was successfully read.

    TryReadQuaternionValue(out Quaternion)

    Try to read the value of the input as a Quaternion.

    Declaration
    protected bool TryReadQuaternionValue(out Quaternion value)
    Parameters
    Type Name Description
    Quaternion value

    When this method returns true, the value read. Otherwise, the default for the type.

    Returns
    Type Description
    bool

    Returns true if the value was successfully read.

    TryReadUIntValue(out uint)

    Try to read the value of the input as an uint.

    Declaration
    protected bool TryReadUIntValue(out uint value)
    Parameters
    Type Name Description
    uint value

    When this method returns true, the value read. Otherwise, the default for the type.

    Returns
    Type Description
    bool

    Returns true if the value was successfully read.

    TryReadValue(out TValue)

    Try to read the current value from the input source.

    Declaration
    public abstract bool TryReadValue(out TValue value)
    Parameters
    Type Name Description
    TValue value

    When this method returns, contains the current value from the input source. May return default(TValue) if unused or no source is set.

    Returns
    Type Description
    bool

    Returns true if the current value was able to be read (and for actions, also if in progress).

    Remarks

    You can use the return value of this method instead of only using ReadValue() in order to avoid doing any work when the input action is not in progress, such as when the control is not actuated. This can be useful for performance reasons.
    If an input processor on an input action returns a different value from the default TValue when the input action is not in progress, the outvalue returned by this method may not be default(TValue) as is typically the case for Try- methods. If you need to support processors that return a different value from the default when the control is not actuated, you should use ReadValue() instead of using the return value of this method to skip input handling.

    TryReadVector2Value(out Vector2)

    Try to read the value of the input as a Vector2.

    Declaration
    protected bool TryReadVector2Value(out Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    When this method returns true, the value read. Otherwise, the default for the type.

    Returns
    Type Description
    bool

    Returns true if the value was successfully read.

    TryReadVector3Value(out Vector3)

    Try to read the value of the input as a Vector3.

    Declaration
    protected bool TryReadVector3Value(out Vector3 value)
    Parameters
    Type Name Description
    Vector3 value

    When this method returns true, the value read. Otherwise, the default for the type.

    Returns
    Type Description
    bool

    Returns true if the value was successfully read.

    Implements

    IXRInputValueReader<TValue>
    IXRInputValueReader
    In This Article
    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)