docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XRInputReaderUtility

    Utility class that provides useful methods for behaviors that use input readers.

    Inheritance
    object
    XRInputReaderUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.Interaction.Toolkit.Inputs.Readers
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    public static class XRInputReaderUtility

    Methods

    SetInputProperty(ref XRInputHapticImpulseProvider, XRInputHapticImpulseProvider, Behaviour)

    Helper method for setting an input property which automatically enables or disables directly serialized embedded input actions during Play mode.

    Declaration
    public static void SetInputProperty(ref XRInputHapticImpulseProvider property, XRInputHapticImpulseProvider value, Behaviour behavior)
    Parameters
    Type Name Description
    XRInputHapticImpulseProvider property

    The ref to the field.

    XRInputHapticImpulseProvider value

    The new value being set.

    Behaviour behavior

    The behavior with the property being set.

    Examples

    This example demonstrates code of a MonoBehaviour that uses an input property:

    [SerializeField]
    XRInputHapticImpulseProvider m_HapticOutput = new XRInputHapticImpulseProvider("Haptic");
    

    public XRInputHapticImpulseProvider hapticOutput { get => m_HapticOutput; set => XRInputReaderUtility.SetInputProperty(ref m_HapticOutput, value, this); }

    void OnEnable() { m_HapticOutput.EnableDirectActionIfModeUsed(); }

    void OnDisable() { m_HapticOutput.DisableDirectActionIfModeUsed(); }

    See Also
    XRInputButtonReader
    XRInputValueReader<TValue>
    XRInputHapticImpulseProvider

    SetInputProperty(ref XRInputButtonReader, XRInputButtonReader, Behaviour)

    Helper method for setting an input property which automatically enables or disables directly serialized embedded input actions during Play mode.

    Declaration
    public static void SetInputProperty(ref XRInputButtonReader property, XRInputButtonReader value, Behaviour behavior)
    Parameters
    Type Name Description
    XRInputButtonReader property

    The ref to the field.

    XRInputButtonReader value

    The new value being set.

    Behaviour behavior

    The behavior with the property being set.

    Examples

    This example demonstrates code of a MonoBehaviour that uses an input property:

    [SerializeField]
    XRInputButtonReader m_GrabMoveInput = new XRInputButtonReader("Grab Move");
    

    public XRInputButtonReader grabMoveInput { get => m_GrabMoveInput; set => XRInputReaderUtility.SetInputProperty(ref m_GrabMoveInput, value, this); }

    void OnEnable() { m_GrabMoveInput.EnableDirectActionIfModeUsed(); }

    void OnDisable() { m_GrabMoveInput.DisableDirectActionIfModeUsed(); }

    See Also
    XRInputButtonReader
    XRInputValueReader<TValue>
    XRInputHapticImpulseProvider

    SetInputProperty<TValue>(ref XRInputValueReader<TValue>, XRInputValueReader<TValue>, Behaviour)

    Helper method for setting an input property which automatically enables or disables directly serialized embedded input actions during Play mode.

    Declaration
    public static void SetInputProperty<TValue>(ref XRInputValueReader<TValue> property, XRInputValueReader<TValue> value, Behaviour behavior) where TValue : struct
    Parameters
    Type Name Description
    XRInputValueReader<TValue> property

    The ref to the field.

    XRInputValueReader<TValue> value

    The new value being set.

    Behaviour behavior

    The behavior with the property being set.

    Type Parameters
    Name Description
    TValue

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

    Examples

    This example demonstrates code of a MonoBehaviour that uses an input property:

    [SerializeField]
    XRInputValueReader<Vector2> m_LeftHandMoveInput = new XRInputValueReader<Vector2>("Left Hand Move");
    

    public XRInputValueReader<Vector2> leftHandMoveInput { get => m_LeftHandMoveInput; set => XRInputReaderUtility.SetInputProperty(ref m_LeftHandMoveInput, value, this); }

    void OnEnable() { m_LeftHandMoveInput.EnableDirectActionIfModeUsed(); }

    void OnDisable() { m_LeftHandMoveInput.DisableDirectActionIfModeUsed(); }

    See Also
    XRInputButtonReader
    XRInputValueReader<TValue>
    XRInputHapticImpulseProvider

    See Also

    XRInputButtonReader
    XRInputValueReader<TValue>
    XRInputHapticImpulseProvider
    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)