Class ARTrackable
The base class for all ARTrackable<TSessionRelativeData, TTrackable> types.
Implements
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Assembly: Unity.XR.ARFoundation.dll
Syntax
public abstract class ARTrackable : MonoBehaviour, ITrackable
Remarks
A "trackable" is something that is tracked in the physical environment. These include:
Properties
nativePtr
The native pointer associated with this trackable.
Declaration
public abstract IntPtr nativePtr { get; }
Property Value
Type | Description |
---|---|
IntPtr | The native pointer. |
Remarks
The data pointed to by this pointer is defined by the provider plug-in implementation. Refer to the provider documentation for each platform your app supports to learn more about the value of this pointer on your target platform(s).
parentId
The TrackableId
of the parent trackable, if any.
Declaration
public virtual TrackableId parentId { get; }
Property Value
Type | Description |
---|---|
TrackableId | The |
pose
The Pose
, in session space, associated with this trackable.
Declaration
public abstract Pose pose { get; }
Property Value
Type | Description |
---|---|
Pose | The pose. |
Examples
Some `ITrackable` implementations are MonoBehaviours, and you can use the Transform component of their GameObjects to access the position and rotation of a trackable in Unity world space. For other trackables without associated GameObjects, you can convert a session-space pose to Unity world space if needed by using the example code below, assuming the XR Origin has a uniform scale of (1, 1, 1):
var origin = FindAnyObjectByType<XROrigin>().transform;
var originPose = new Pose(origin.position, origin.rotation);
var worldSpacePose = pose.GetTransformedBy(xrOriginPose);
trackableId
The TrackableId
associated with this trackable.
Declaration
public abstract TrackableId trackableId { get; }
Property Value
Type | Description |
---|---|
TrackableId | The |
trackingState
The TrackingState
associated with this trackable.
Declaration
public abstract TrackingState trackingState { get; }
Property Value
Type | Description |
---|---|
TrackingState | The |
Methods
OnDestroy()
Notifies AR Foundation's internal systems that this trackable has been destroyed.
Declaration
protected void OnDestroy()
Remarks
If you override Unity's OnDestroy
method in your ARTrackable
-derived type, call
base.OnDestroy
to ensure that AR Foundation is notified when your trackable type is destroyed.