API reference
API reference
Select your platform
No SDKs available
No versions available

OVRLocatable Struct

Extends IEquatable< OVRLocatable >
Represents the Pose of the anchor.
Enabling it will localize the anchor.
This component can be accessed from an OVRAnchor that supports it by calling OVRAnchor.GetComponent<T> from the anchor.
This component needs to be enabled before requesting its Pose. See IsEnabled and SetEnabledAsync
Read more about anchors generally at Spatial Anchors Overview

Static Fields

Null : readonly OVRLocatable
A null representation of an OVRLocatable.
Use this to compare with another component to determine whether it is null.
Signature
readonly OVRLocatable Null

Properties

IsEnabled : bool
[Get]
True if this component is enabled and no change to its enabled status is pending.
Signature
bool IsEnabled
IsNull : bool
[Get]
Whether this object represents a valid anchor component.
Signature
bool IsNull

Methods

Equals ( other )
Compares this component for equality with other .
Signature
bool Equals(OVRLocatable other)
Parameters
other: OVRLocatable  The other component to compare with.
Returns
bool  True if both components belong to the same OVRAnchor, otherwise false.
Equals ( obj )
Compares this component for equality with obj .
Signature
override bool Equals(object obj)
Parameters
obj: object  The object to compare with.
Returns
override bool  True if obj is an OVRLocatable and Equals(OVRLocatable) is true, otherwise false.
GetHashCode ()
Gets a hashcode suitable for use in a Dictionary or HashSet.
Signature
override int GetHashCode()
Returns
override int  A hashcode for this component.
SetEnabledAsync ( enabled , timeout )
Sets the enabled status of this component.
A component must be enabled in order to access its data or do enable its functionality.
This method is asynchronous. Use the returned task to track the completion of this operation. The task's value indicates whether the operation was successful.
If the current enabled state matches enabled , then the returned task completes immediately with a true result. If there is already a pending change to the enabled state, the new request is queued.
Signature
OVRTask< bool > SetEnabledAsync(bool enabled, double timeout=0)
Parameters
enabled: bool  The desired state of the component.
timeout: double  The timeout, in seconds, for the operation. Use zero to indicate an infinite timeout.
Returns
OVRTask< bool >  Returns an OVRTask<bool> whose result indicates the result of the operation.
SetEnabledSafeAsync ( enabled , timeout )
(Obsolete) Sets the enabled status of this component if it differs from the current enabled state.
This method is obsolete. Use SetEnabledAsync instead.
Signature
OVRTask< bool > SetEnabledSafeAsync(bool enabled, double timeout=0)
Parameters
enabled: bool  The desired state of the component.
timeout: double  The timeout, in seconds, for the operation. Use zero to indicate an infinite timeout.
Returns
OVRTask< bool >  Returns an OVRTask<bool> whose result indicates the result of the operation.
ToString ()
Gets a string representation of this component.
Signature
override string ToString()
Returns
override string  A string representation of this component.
TryGetSceneAnchorPose ( pose )
Tries to get the TrackingSpacePose representing the position and rotation of this anchor, treated as a scene anchor, in tracking space.
Although the request may succeed and provide a valid TrackingSpacePose, actual Position and Rotation provided may not be valid and/or tracked, see TrackingSpacePose for more information on how to use its data.
Scene anchors follow a different transform from the raw OpenXR data than spatial anchors'.
Signature
bool TryGetSceneAnchorPose(out TrackingSpacePose pose)
Parameters
pose: out TrackingSpacePose  The out TrackingSpacePose which will get filled in.
Returns
bool  True if the request was successful, False otherwise.
TryGetSpatialAnchorPose ( pose )
Tries to get the TrackingSpacePose representing the position and rotation of this anchor, treated as a spatial anchor, in tracking space.
Although the request may succeed and provide a valid TrackingSpacePose, actual position and rotation provided may not be valid and/or tracked, see TrackingSpacePose for more information on how to use its data.
Spatial anchors follow a different transform from the raw OpenXR data than scene anchors'.
Signature
bool TryGetSpatialAnchorPose(out TrackingSpacePose pose)
Parameters
pose: out TrackingSpacePose  The out TrackingSpacePose which will get filled in.
Returns
bool  True if the request was successful, False otherwise.

Static Methods

operator!= ( lhs , rhs )
Compares two components for inequality.
Signature
static bool operator!=(OVRLocatable lhs, OVRLocatable rhs)
Parameters
lhs: OVRLocatable  The component to compare with rhs .
rhs: OVRLocatable  The component to compare with lhs .
Returns
bool  True if the components do not belong to the same OVRAnchor, otherwise false.
operator== ( lhs , rhs )
Compares two components for equality.
Signature
static bool operator==(OVRLocatable lhs, OVRLocatable rhs)
Parameters
lhs: OVRLocatable  The component to compare with rhs .
rhs: OVRLocatable  The component to compare with lhs .
Returns
bool  True if both components belong to the same OVRAnchor, otherwise false.
UpdateSceneAnchorTransforms ( anchors , trackingSpaceToWorldSpaceTransform , trackingSpacePoses )
Sets a collection of transforms according to a parallel collection of anchors.
This method accepts a collection of OVRAnchor-Transform pairs and attempts to get each anchor's pose, then apply it to the corresponding Transform.
A TrackingSpacePose has a position and rotation, either of which may be valid and tracked. If a component is not valid, it is ignored (not written to the corresponding Transform in anchors ). If it is valid but not tracked, it is still written to the corresponding Transform.
Example usage:
class MyBehaviour : MonoBehaviour
{
    [SerializeField] OVRCameraRig _cameraRig;

    Dictionary<OVRAnchor, Transform> _anchors = new();

    void Update()
    {
        OVRLocatable.UpdateSceneAnchorTransforms(_anchors, _cameraRig.transform, null);
    }
}
This method is similar to calling TryGetSceneAnchorPose on each OVRAnchor in anchors and applying the result to each Transform in anchors . However, it correctly handles all permutations of pose validity and is more efficient to perform as a batch operation.
Signature
static void UpdateSceneAnchorTransforms(IEnumerable< KeyValuePair< OVRAnchor, Transform > > anchors, Transform trackingSpaceToWorldSpaceTransform=null, List< TrackingSpacePose > trackingSpacePoses=null)
Parameters
anchors: IEnumerable< KeyValuePair< OVRAnchor, Transform > >  A collection of anchor-transform pairs. The pose of each OVRAnchor is used to set its corresponding Transform.
trackingSpaceToWorldSpaceTransform: Transform  (Optional) The transform to apply to each pose before setting the corresponding transform in anchors . If not null, this transform is applied to the pose, and this method then sets the world space transform. If null, no transform is applied and the local space transform is set.
trackingSpacePoses: List< TrackingSpacePose >  (Optional) If not null, trackingSpacePoses is cleared and then the TrackingSpacePose of each OVRAnchor is added to it. This is an optional parameter, but may be useful information since it also tells you whether a pose is valid and tracked.
Returns
void
Throws
ArgumentNullException  Thrown if anchors is null.

Inner Structs

GetSceneAnchorPosesJob Struct

Extends IJobFor
A job for determining the pose of an array of scene anchors.
This is a jobified version of OVRLocatable.TryGetSceneAnchorPose. The TrackingSpacePose for each OVRLocatable in Locatables is determined and written to Poses.
The length of Locatables and Poses must be equal.
An element of Locatables may be invalid (that is, OVRLocatable.IsNull is true), in which case the TrackingSpacePose.Position and TrackingSpacePose.Rotation properties corresponding to this OVRLocatable will be null.
Read more about Unity's job system here.

Fields

Locatables : NativeArray< OVRLocatable >
The array of locatable components from which to read the anchor's pose.
This array must have the same length as Poses.
Signature
NativeArray<OVRLocatable> Locatables
Poses : NativeArray< TrackingSpacePose >
The array of TrackingSpacePoses in which to store the resulting pose.
This array must have the same length as Locatables.
Signature
NativeArray<TrackingSpacePose> Poses

Methods

Execute ( index )
Signature
void IJobFor. Execute(int index)
Parameters
index: int
Returns
void IJobFor.

GetSpatialAnchorPosesJob Struct

Extends IJobFor
A job for determining the pose of an array of spatial anchors.
This is a jobified version of OVRLocatable.TryGetSpatialAnchorPose. The TrackingSpacePose for each OVRLocatable in Locatables is determined and written to Poses.
The length of Locatables and Poses must be equal.
An element of Locatables may be invalid (that is, OVRLocatable.IsNull is true), in which case the TrackingSpacePose.Position and TrackingSpacePose.Rotation properties corresponding to this OVRLocatable will be null.
Read more about Unity's job system here.

Fields

Locatables : NativeArray< OVRLocatable >
The array of locatable components from which to read the anchor's pose.
This array must have the same length as Poses.
Signature
NativeArray<OVRLocatable> Locatables
Poses : NativeArray< TrackingSpacePose >
The array of TrackingSpacePoses in which to store the resulting pose.
This array must have the same length as Locatables.
Signature
NativeArray<TrackingSpacePose> Poses

Methods

Execute ( index )
Signature
void IJobFor. Execute(int index)
Parameters
index: int
Returns
void IJobFor.

SetLocalSpaceTransformsJob Struct

Extends IJobParallelForTransform
Sets the local space transform of Unity transforms according to an array of TrackingSpacePose.
This job reads the poses in Poses and uses them to set the local space transform of each UnityEngine.Transform described by a TransformAccessArray.
A TrackingSpacePose consists of a position and rotation, either of which may be valid or invalid. This job sets the transform's position and rotation depending on whether they are valid.

Fields

Poses : NativeArray< TrackingSpacePose >
Signature
NativeArray<TrackingSpacePose> Poses

Methods

Execute ( index , transform )
Signature
void Execute(int index, TransformAccess transform)
Parameters
index: int
transform: TransformAccess
Returns
void

SetWorldSpaceTransformsJob Struct

Extends IJobParallelForTransform
Sets the world space transform of Unity transforms according to an array of TrackingSpacePose.
This job reads the poses in Poses and uses them to set the world space transform of each UnityEngine.Transform described by a TransformAccessArray.
You can chain this job with a TransformPosesJob to first transform Pose into world space.

Fields

Poses : NativeArray< TrackingSpacePose >
The array of poses to apply to each element of the TransformAccessArray.
Signature
NativeArray<TrackingSpacePose> Poses

Methods

Execute ( index , transform )
Signature
void IJobParallelForTransform. Execute(int index, TransformAccess transform)
Parameters
index: int
transform: TransformAccess
Returns
void IJobParallelForTransform.

TrackingSpacePose Struct

Tracking space position and rotation of the anchor.
Obtain a TrackingSpacePose from OVRLocatable.TryGetSceneAnchorPose or OVRLocatable.TryGetSpatialAnchorPose depending on the type of anchor you wish to interpret it as.
Position and rotation are both nullable Vector3 and Quaternion and might be null independently if one of them or both are invalid.

Properties

IsPositionTracked : bool
[Get]
Indicates whether the position is currently tracked.
Signature
bool IsPositionTracked
IsRotationTracked : bool
[Get]
Indicates whether the rotation is currently tracked.
Signature
bool IsRotationTracked
Position : Vector3?
[Get]
Position in tracking space of the anchor.
Null if and when the rotation is invalid. This constitutes the positional aspect of the anchor's pose. See Rotation for the rotational part.
Signature
Vector3? Position
Rotation : Quaternion?
[Get]
Rotation in tracking space of the anchor.
Null if and when the rotation is invalid. This constitutes the rotational aspect of the anchor's pose. See Position for the positional part.
Signature
Quaternion? Rotation

Methods

ComputeWorldPosition ( camera )
DeprecatedComputes the world space position of the anchor
Signature
Vector3? ComputeWorldPosition(Camera camera)
Parameters
camera: Camera  A Camera component that will be use to compute the transform to world space
Returns
Vector3?  Returns the nullable Vector3 position in world space which may be null if and when Position is invalid or head pose is invalid.
Throws
ArgumentNullException  If camera is null
ComputeWorldPosition ( trackingSpaceToWorldSpaceTransform )
Computes the world-space position of the anchor.
Signature
Vector3? ComputeWorldPosition(Transform trackingSpaceToWorldSpaceTransform)
Parameters
trackingSpaceToWorldSpaceTransform: Transform  Uses this transform to convert position from tracking-space to world-space.
Returns
Vector3?  The world-space position of the anchor, or null if Position does not have a value.
ComputeWorldRotation ( camera )
DeprecatedComputes the world space rotation of the anchor
Signature
Quaternion? ComputeWorldRotation(Camera camera)
Parameters
camera: Camera  A Camera component that will be use to compute the transform to world space
Returns
Quaternion?  The nullable Quaternion rotation in world space which may be null if and when Rotation is invalid or if head rotation is invalid.
Throws
ArgumentNullException  If camera is null
ComputeWorldRotation ( trackingSpaceToWorldSpaceTransform )
Computes the world-space rotation of the anchor.
Signature
Quaternion? ComputeWorldRotation(Transform trackingSpaceToWorldSpaceTransform)
Parameters
trackingSpaceToWorldSpaceTransform: Transform  Uses this transform to convert rotation from tracking-space to world-space.
Returns
Quaternion?  The world-space rotation of the anchor, or null if Rotation does not have a value.

TransformPosesJob Struct

Extends IJobFor
A job which transforms an array of TrackingSpacePose to a new space.
This job multiples each TrackingSpacePose in Poses by Transform and stores the result back into Poses (that is, in-place).
This job is useful for converting an anchor's tracking space pose into world space:
void TransformPoses(NativeArray<TrackingSpacePose> poses, Transform transform)
{
    var jobHandle = new TransformPosesJob
    {
        Poses = poses,
        Transform = transform.localToWorldMatrix,
        Rotation = transform.rotation,
    }.Schedule(poses.Length);
}
Read more about Unity's job system here.

Fields

Poses : NativeArray< TrackingSpacePose >
The poses to transform.
Signature
NativeArray<TrackingSpacePose> Poses
Rotation : Quaternion
The rotation to apply to each TrackingSpacePose rotation in Poses.
Typically, this should be the rotational component of Transform. It is separate because the rotation is not guaranteed to be extracted from a Matrix4x4 if, for example, it has non-uniform scale.
Signature
Quaternion Rotation
Transform : Matrix4x4
The transform to apply to each TrackingSpacePose position in Poses.
You can generate a Matrix4x4 from a UnityEngine.Transform with transform.localToWorldMatrix.
Signature
Matrix4x4 Transform

Methods

Execute ( index )
Signature
void IJobFor. Execute(int index)
Parameters
index: int
Returns
void IJobFor.