Struct XRHandJoint
Represents a joint of an XRHand.
Inherited Members
Namespace: UnityEngine.XR.Hands
Syntax
public struct XRHandJoint : IEquatable<XRHandJoint>
Remarks
The term "joint" should be taken loosely in this context. In addition to the anatomical finger joints, the list of joints includes the fingertips, a point on the palm and a point on the wrist. See XRHandJointID for the full list of joints.
Refer to Hand data model for a description of the joint locations and the data they contain.
Properties
handedness
Denotes which hand this joint is on.
Declaration
public readonly Handedness handedness { get; }
Property Value
| Type | Description |
|---|---|
| Handedness | Right or left. |
id
The ID of this joint.
Declaration
public readonly XRHandJointID id { get; }
Property Value
| Type | Description |
|---|---|
| XRHandJointID | The joint ID. |
trackingState
Represents which tracking data is valid.
Declaration
public readonly XRHandJointTrackingState trackingState { get; }
Property Value
| Type | Description |
|---|---|
| XRHandJointTrackingState | A flag is set for each valid type of data. If the The WillNeverBeValid flag is set when this joind ID isn't supported by the hand data provider. |
Methods
Equals(Object)
Tests for equality.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj | An Object to compare against. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if |
Overrides
Equals(XRHandJoint)
Tests for equality.
Declaration
public bool Equals(XRHandJoint other)
Parameters
| Type | Name | Description |
|---|---|---|
| XRHandJoint | other | The XRHandJoint to compare against. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if the underlying native pointers are the same. Returns false otherwise. |
Implements
GetHashCode()
Computes a hash code from all fields of XRHandJoint.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| Int32 | Returns a hash code of this object. |
Overrides
ToString()
Returns a string representation of the XRHandJoint.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String | String representation of the value. |
Overrides
TryGetAngularVelocity(out Vector3)
Retrieves the joint's angular velocity vector, if available
Declaration
public bool TryGetAngularVelocity(out Vector3 angularVelocity)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | angularVelocity | Assigned the tracked angular velocity of this joint, if successful. Set to zero, if unsuccessful. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if successful and the angular velocity filled out with valid tracking data, returns false otherwise. |
Remarks
To transform to world space so that the vector has the correct direction relative to the user, rotate this by the rotation of the XROrigin.
TryGetLinearVelocity(out Vector3)
Retrieves the joint's linear velocity vector, if available.
Declaration
public bool TryGetLinearVelocity(out Vector3 linearVelocity)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | linearVelocity | Assigned the tracked linear velocity of this joint, if successful. Set to zero, if unsuccessful. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if successful and the velocity was filled out with valid tracking data, returns false otherwise. |
Remarks
To transform to world space so that the vector has the correct direction relative to the user, rotate this by the rotation of the XROrigin.
TryGetPose(out Pose)
Retrieves the joint's pose, if available.
Declaration
public bool TryGetPose(out Pose pose)
Parameters
| Type | Name | Description |
|---|---|---|
| Pose | pose | Assigned the tracked pose of this joint, if successful. Set to identity, if unsuccessful. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if successful and the joint pose was filled out with valid tracking data, returns false otherwise. |
Remarks
Joint poses are relative to the real-world point chosen by the user's device.
To transform to world space so that the joint appears in the correct location relative to the user, transform the pose based on the XROrigin.
Examples
The following example illustrates how to transform a pose into world space using the transform from the XROrigin object in a scene.
public Pose ToWorldPose(XRHandJoint joint, Transform origin)
{
Pose xrOriginPose = new Pose(origin.position, origin.rotation);
if (joint.TryGetPose(out Pose jointPose))
{
return jointPose.GetTransformedBy(xrOriginPose);
}
else
{
return Pose.identity;
}
}
TryGetRadius(out Single)
Retrieves the joint's radius, if available.
Declaration
public bool TryGetRadius(out float radius)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | radius | Assigned the tracked radius of this joint, if successful. Set to zero, if unsuccessful. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if successful and the radius was filled out with valid tracking data, returns false otherwise. |
Operators
Equality(XRHandJoint, XRHandJoint)
Tests for equality. Same as Equals(XRHandJoint).
Declaration
public static bool operator ==(XRHandJoint lhs, XRHandJoint rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| XRHandJoint | lhs | The left-hand side of the comparison. |
| XRHandJoint | rhs | The right-hand side of the comparison. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns the same value as Equals(XRHandJoint). |
Inequality(XRHandJoint, XRHandJoint)
Tests for inequality. Same as !Equals(XRHandJoint)
Declaration
public static bool operator !=(XRHandJoint lhs, XRHandJoint rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| XRHandJoint | lhs | The left-hand side of the comparison. |
| XRHandJoint | rhs | The right-hand side of the comparison. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns the negation of Equals(XRHandJoint). |