Class MetaAimHand
A UnityEngine.InputSystem.TrackedDevice based off the data exposed in the Meta Hand Tracking Aim extension. Enabled through Meta Hand Tracking Aim or by enabling hand-tracking in the Oculus plug-in if the Input System back-end is enabled.
Inherited Members
Namespace: UnityEngine.XR.Hands
Assembly: Unity.XR.Hands.dll
Syntax
[InitializeOnLoad]
[Preserve]
public class MetaAimHand : TrackedDevice
Remarks
For this type to function, you must enable hand-tracking and be running with either the OpenXR or Oculus plug-in.
The UnityEngine.InputSystem.TrackedDevice.devicePosition and UnityEngine.InputSystem.TrackedDevice.deviceRotation inherited from UnityEngine.InputSystem.TrackedDevice represent the aim pose. You can use these values to discover the target for pinch gestures, when appropriate.
Use the XROrigin in the scene to position and orient
the device properly. If you are using this data to set the Transform of a GameObject in
the scene hierarchy, you can set the local position and rotation of the Transform and make
it a child of the CameraOffset
object below the XROrigin
. Otherwise, you can use the
Transform of the CameraOffset
to transform the data into world space.
Fields
pressThreshold
The pinch amount required to register as being pressed for the purposes of indexPressed, middlePressed, ringPressed, and littlePressed.
Declaration
public const float pressThreshold = 0.8
Field Value
Type | Description |
---|---|
float |
Properties
aimFlags
Cast the result of reading this to MetaAimFlags to examine the value.
Declaration
[Preserve]
public IntegerControl aimFlags { get; }
Property Value
Type | Description |
---|---|
IntegerControl |
indexPressed
A ButtonControl
that represents whether the pinch between the index finger and
the thumb is mostly pressed (greater than a threshold of 0.8
contained in pressThreshold).
Declaration
[Preserve]
public ButtonControl indexPressed { get; }
Property Value
Type | Description |
---|---|
ButtonControl |
left
The left-hand InputDevice that contains UnityEngine.InputSystem.InputControls that surface data in the Meta Hand Tracking Aim extension.
Declaration
public static MetaAimHand left { get; set; }
Property Value
Type | Description |
---|---|
MetaAimHand |
Remarks
It is recommended that you treat this as read-only, and do not set it yourself. It will be set for you if hand-tracking has been enabled and if you are running with either the OpenXR or Oculus plug-in.
littlePressed
A ButtonControl
that represents whether the pinch between the little finger and
the thumb is mostly pressed (greater than a threshold of 0.8
contained in pressThreshold).
Declaration
[Preserve]
public ButtonControl littlePressed { get; }
Property Value
Type | Description |
---|---|
ButtonControl |
middlePressed
A ButtonControl
that represents whether the pinch between the middle finger and
the thumb is mostly pressed (greater than a threshold of 0.8
contained in pressThreshold).
Declaration
[Preserve]
public ButtonControl middlePressed { get; }
Property Value
Type | Description |
---|---|
ButtonControl |
pinchStrengthIndex
An AxisControl that represents the pinch strength between the index finger and the thumb.
Declaration
[Preserve]
public AxisControl pinchStrengthIndex { get; }
Property Value
Type | Description |
---|---|
AxisControl |
Remarks
A value of 0
denotes no pinch at all, while a value of
1
denotes a full pinch.
pinchStrengthLittle
An AxisControl that represents the pinch strength between the little finger and the thumb.
Declaration
[Preserve]
public AxisControl pinchStrengthLittle { get; }
Property Value
Type | Description |
---|---|
AxisControl |
Remarks
A value of 0
denotes no pinch at all, while a value of
1
denotes a full pinch.
pinchStrengthMiddle
An AxisControl that represents the pinch strength between the middle finger and the thumb.
Declaration
[Preserve]
public AxisControl pinchStrengthMiddle { get; }
Property Value
Type | Description |
---|---|
AxisControl |
Remarks
A value of 0
denotes no pinch at all, while a value of
1
denotes a full pinch.
pinchStrengthRing
An AxisControl that represents the pinch strength between the ring finger and the thumb.
Declaration
[Preserve]
public AxisControl pinchStrengthRing { get; }
Property Value
Type | Description |
---|---|
AxisControl |
Remarks
A value of 0
denotes no pinch at all, while a value of
1
denotes a full pinch.
right
The right-hand InputDevice that contains UnityEngine.InputSystem.InputControls that surface data in the Meta Hand Tracking Aim extension.
Declaration
public static MetaAimHand right { get; set; }
Property Value
Type | Description |
---|---|
MetaAimHand |
Remarks
It is recommended that you treat this as read-only, and do not set it yourself. It will be set for you if hand-tracking has been enabled and if you are running with either the OpenXR or Oculus plug-in.
ringPressed
A ButtonControl
that represents whether the pinch between the ring finger and
the thumb is mostly pressed (greater than a threshold of 0.8
contained in pressThreshold).
Declaration
[Preserve]
public ButtonControl ringPressed { get; }
Property Value
Type | Description |
---|---|
ButtonControl |
Methods
CreateHand(InputDeviceCharacteristics)
Creates a MetaAimHand and adds it to the Input System.
Declaration
public static MetaAimHand CreateHand(InputDeviceCharacteristics extraCharacteristics)
Parameters
Type | Name | Description |
---|---|---|
InputDeviceCharacteristics | extraCharacteristics | Additional characteristics to build the hand device with besides HandTracking and TrackedDevice. |
Returns
Type | Description |
---|---|
MetaAimHand | A MetaAimHand retrieved from UnityEngine.InputSystem.InputSystem.AddDevice(UnityEngine.InputSystem.Layouts.InputDeviceDescription). |
Remarks
It is recommended that you do not call this yourself. It will be called for you at the appropriate time if hand-tracking has been enabled and if you are running with either the OpenXR or Oculus plug-in.
FinishSetup()
Perform final initialization tasks after the control hierarchy has been put into place.
Declaration
protected override void FinishSetup()
Overrides
UpdateHand(bool, MetaAimFlags, Pose, float, float, float, float)
Queues update events in the Input System based on the supplied hand. It is not recommended that you call this directly. This will be called for you when appropriate.
Declaration
public void UpdateHand(bool isHandRootTracked, MetaAimFlags aimFlags, Pose aimPose, float pinchIndex, float pinchMiddle, float pinchRing, float pinchLittle)
Parameters
Type | Name | Description |
---|---|---|
bool | isHandRootTracked | Whether the hand root pose is valid. |
MetaAimFlags | aimFlags | The aim flags to update in the Input System. |
Pose | aimPose | The aim pose to update in the Input System. Used if the hand root is tracked. |
float | pinchIndex | The pinch strength for the index finger to update in the Input System. |
float | pinchMiddle | The pinch strength for the middle finger to update in the Input System. |
float | pinchRing | The pinch strength for the ring finger to update in the Input System. |
float | pinchLittle | The pinch strength for the little finger to update in the Input System. |
UpdateHand(MetaAimFlags, Pose, float, float, float, float)
Queues update events in the Input System based on the supplied hand. It is not recommended that you call this directly. This will be called for you when appropriate.
Declaration
[Obsolete("Use the UpdateHand that has an additional first bool parameter for whether the hand is tracked, or the device pose won't update correctly.")]
public void UpdateHand(MetaAimFlags aimFlags, Pose aimPose, float pinchIndex, float pinchMiddle, float pinchRing, float pinchLittle)
Parameters
Type | Name | Description |
---|---|---|
MetaAimFlags | aimFlags | The aim flags to update in the Input System. |
Pose | aimPose | The aim pose to update in the Input System. |
float | pinchIndex | The pinch strength for the index finger to update in the Input System. |
float | pinchMiddle | The pinch strength for the middle finger to update in the Input System. |
float | pinchRing | The pinch strength for the ring finger to update in the Input System. |
float | pinchLittle | The pinch strength for the little finger to update in the Input System. |