Class FollowPreset
Class that defines the configuration of a following behaviour for a hand or object. It determines how an object should follow the hand and includes specifications about local position and rotation, angle constraints, gaze snapping, and smoothing settings.
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.UI.BodyUI
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[Serializable]
public class FollowPreset
Fields
allowSmoothing
Whether to allow smoothing of the following element position and rotation.
Declaration
[Header("Smoothing Config")]
[Tooltip("Whether to allow smoothing of the following element position and rotation.")]
public bool allowSmoothing
Field Value
| Type | Description |
|---|---|
| bool |
followLowerSmoothingValue
The lower bound of smoothing to apply.
Declaration
[Tooltip("The lower bound of smoothing to apply.")]
public float followLowerSmoothingValue
Field Value
| Type | Description |
|---|---|
| float |
followUpperSmoothingValue
The upper bound of smoothing to apply.
Declaration
[Tooltip("The upper bound of smoothing to apply.")]
public float followUpperSmoothingValue
Field Value
| Type | Description |
|---|---|
| float |
hideDelaySeconds
The amount of time in seconds to wait before hiding the following element after the hand is no longer tracked.
Declaration
[Header("Hide delay config")]
[Tooltip("The amount of time in seconds to wait before hiding the following element after the hand is no longer tracked.")]
public float hideDelaySeconds
Field Value
| Type | Description |
|---|---|
| float |
invertAxisForRightHand
Given that the default reference hand for menus is the left hand, it may be required to mirror the reference axis for the right hand. This is not necessary if using the up or down axis as a reference, which is the default for hand tracking. Controllers work best with the right and left axies.
Declaration
[Tooltip("Given that the default reference hand for menus is the left hand, it may be required to mirror the reference axis for the right hand.")]
public bool invertAxisForRightHand
Field Value
| Type | Description |
|---|---|
| bool |
leftHandLocalPosition
Local space anchor position for the left hand.
Declaration
[Tooltip("Local space anchor position for the left hand.")]
public Vector3 leftHandLocalPosition
Field Value
| Type | Description |
|---|---|
| Vector3 |
leftHandLocalRotation
Local space anchor rotation for the left hand.
Declaration
[Tooltip("Local space anchor rotation for the left hand.")]
public Vector3 leftHandLocalRotation
Field Value
| Type | Description |
|---|---|
| Vector3 |
palmFacingUpDegreeAngleThreshold
Angle threshold to check if the palm reference axis is facing up.
Declaration
[Tooltip("The angle threshold in degrees to check if the palm reference axis is facing up.")]
public float palmFacingUpDegreeAngleThreshold
Field Value
| Type | Description |
|---|---|
| float |
palmFacingUserDegreeAngleThreshold
Angle threshold to check if the palm reference axis is facing the user.
Declaration
[Tooltip("The angle threshold in degrees to check if the palm reference axis is facing the user.")]
public float palmFacingUserDegreeAngleThreshold
Field Value
| Type | Description |
|---|---|
| float |
palmReferenceAxis
Reference axis equivalent used for comparisons with the user's gaze direction and the world up direction.
Declaration
[Header("Hand anchor angle constraints")]
[Tooltip("Reference axis equivalent used for comparisons with the user's gaze direction and the world up direction.")]
public FollowReferenceAxis palmReferenceAxis
Field Value
| Type | Description |
|---|---|
| FollowReferenceAxis |
requirePalmFacingUp
Check status of palm reference axis facing up.
Declaration
[Tooltip("Whether or not check if the palm reference axis is facing up.")]
public bool requirePalmFacingUp
Field Value
| Type | Description |
|---|---|
| bool |
requirePalmFacingUser
Check status of palm reference axis facing the user.
Declaration
[Tooltip("Whether or not check if the palm reference axis is facing the user.")]
public bool requirePalmFacingUser
Field Value
| Type | Description |
|---|---|
| bool |
rightHandLocalPosition
Local space anchor position for the right hand.
Declaration
[Header("Local Space Anchor Transform")]
[Tooltip("Local space anchor position for the right hand.")]
public Vector3 rightHandLocalPosition
Field Value
| Type | Description |
|---|---|
| Vector3 |
rightHandLocalRotation
Local space anchor rotation for the right hand.
Declaration
[Tooltip("Local space anchor rotation for the right hand.")]
public Vector3 rightHandLocalRotation
Field Value
| Type | Description |
|---|---|
| Vector3 |
snapToGaze
Configures the snap to gaze option.
Declaration
[Header("Snap To gaze config")]
[Tooltip("Whether to snap the following element to the gaze direction.")]
public bool snapToGaze
Field Value
| Type | Description |
|---|---|
| bool |
snapToGazeAngleThreshold
The angle threshold in degrees to snap the following element to the gaze direction.
Declaration
[Tooltip("The angle threshold in degrees to snap the following element to the gaze direction.")]
public float snapToGazeAngleThreshold
Field Value
| Type | Description |
|---|---|
| float |
Properties
palmFacingUpDotThreshold
The dot product equivalent to the angle threshold used to check if the palm reference axis is facing up.
Declaration
public float palmFacingUpDotThreshold { get; }
Property Value
| Type | Description |
|---|---|
| float |
palmFacingUserDotThreshold
The dot product equivalent to the angle threshold used to check if the palm reference axis is facing the user.
Declaration
public float palmFacingUserDotThreshold { get; }
Property Value
| Type | Description |
|---|---|
| float |
snapToGazeDotThreshold
Dot product threshold for snap to gaze.
Declaration
public float snapToGazeDotThreshold { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
ApplyPreset(Transform, Transform)
Applies this preset to the specified tracking offsets for the left and right local positions and rotations. Also recomputes dot product thresholds.
Declaration
public void ApplyPreset(Transform leftTrackingOffset, Transform rightTrackingOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | leftTrackingOffset | The Transform object that represents the left tracking offset. |
| Transform | rightTrackingOffset | The Transform object that represents the right tracking offset. |
ComputeDotProductThresholds()
Update the dot product thresholds based on the current angle thresholds.
Declaration
public void ComputeDotProductThresholds()
GetReferenceAxisForTrackingAnchor(Transform, bool)
Gets the reference axis relative to the specified tracking root. Adjusts the return value depending on whether or not this is for the user's right hand.
Declaration
public Vector3 GetReferenceAxisForTrackingAnchor(Transform trackingRoot, bool isRightHand)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | trackingRoot | Tracking root Transform. |
| bool | isRightHand | Whether this is for the user's right hand or not. |
Returns
| Type | Description |
|---|---|
| Vector3 | Returns a Vector3 representing the reference axis relative to the specified tracking root. |