Class ARTrackedObjectManager
A manager for ARTrackedObjects. Uses the XRObjectTrackingSubsystem
to recognize and track 3D Objects in the physical environment.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Syntax
[DefaultExecutionOrder(-2147483647)]
[DisallowMultipleComponent]
[RequireComponent(typeof(ARSessionOrigin))]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.0/api/UnityEngine.XR.ARFoundation.ARTrackedObjectManager.html")]
public sealed class ARTrackedObjectManager : ARTrackableManager<XRObjectTrackingSubsystem, XRObjectTrackingSubsystemDescriptor, XRTrackedObject, ARTrackedObject>
Properties
gameObjectName
The name to be used for the GameObject
whenever a new Object is detected.
Declaration
protected override string gameObjectName { get; }
Property Value
Type | Description |
---|---|
String |
Overrides
referenceLibrary
The ARObjectLibrary
to use during Object detection. This is the
library of objects which will be detected and/or tracked in the physical environment.
Declaration
public XRReferenceObjectLibrary referenceLibrary { get; set; }
Property Value
Type | Description |
---|---|
XRReferenceObjectLibrary |
trackedObjectPrefab
If not null, instantiates this prefab for each detected object.
Declaration
public GameObject trackedObjectPrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
Methods
GetPrefab()
Get the prefab to instantiate for each ARTrackedObject.
Declaration
protected override GameObject GetPrefab()
Returns
Type | Description |
---|---|
GameObject | The prefab to instantiate for each ARTrackedObject. |
Overrides
OnAfterSetSessionRelativeData(ARTrackedObject, XRTrackedObject)
Invoked just after each ARTrackedObject has been updated.
Declaration
protected override void OnAfterSetSessionRelativeData(ARTrackedObject trackedObject, XRTrackedObject sessionRelativeData)
Parameters
Type | Name | Description |
---|---|---|
ARTrackedObject | trackedObject | The ARTrackedObject being updated. |
XRTrackedObject | sessionRelativeData | New data associated with |
Overrides
OnBeforeStart()
Sets the Object library on the subsystem before Start() is called on the base class.
Declaration
protected override void OnBeforeStart()
Overrides
OnTrackablesChanged(List<ARTrackedObject>, List<ARTrackedObject>, List<ARTrackedObject>)
Invokes the trackedObjectsChanged event.
Declaration
protected override void OnTrackablesChanged(List<ARTrackedObject> added, List<ARTrackedObject> updated, List<ARTrackedObject> removed)
Parameters
Type | Name | Description |
---|---|---|
List<ARTrackedObject> | added | A list of objects added this frame. |
List<ARTrackedObject> | updated | A list of objects updated this frame. |
List<ARTrackedObject> | removed | A list of objects removed this frame. |
Overrides
Events
trackedObjectsChanged
Invoked once per frame with information about the ARTrackedObjects that have changed, i.e., been added, updated, or removed.
This happens just before ARTrackedObjects are destroyed, so you can set ARTrackedObject.destroyOnRemoval
to false
from this event to suppress this behavior.
Declaration
public event Action<ARTrackedObjectsChangedEventArgs> trackedObjectsChanged
Event Type
Type | Description |
---|---|
Action<ARTrackedObjectsChangedEventArgs> |