docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IXRInputValueReader<TValue>

    Interface which allows for callers to read the current value from an input source.

    Namespace: UnityEngine.XR.Interaction.Toolkit.Inputs.Readers
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    public interface IXRInputValueReader<TValue> : IXRInputValueReader where TValue : struct
    Type Parameters
    Name Description
    TValue

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

    Methods

    ReadValue()

    Read the current value from the input source.

    Declaration
    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.

    See Also
    XRInputValueReader

    TryReadValue(out TValue)

    Try to read the current value from the input source.

    Declaration
    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 out value 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.

    See Also
    XRInputValueReader

    See Also

    XRInputValueReader
    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)