Class XRInputReaderUtility
Utility class that provides useful methods for behaviors that use input readers.
Inherited Members
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 |
---|---|---|
XRInput |
property | The ref to the field. |
XRInput |
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
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 |
---|---|---|
XRInput |
property | The ref to the field. |
XRInput |
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
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 |
---|---|---|
XRInput |
property | The ref to the field. |
XRInput |
value | The new value being set. |
Behaviour | behavior | The behavior with the property being set. |
Type Parameters
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();
}