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
Inherited Members
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 |
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 |
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 |
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. |