Class ARTrackedImageManager
A manager for ARTrackedImages. Uses the XRImageTrackingSubsystem
to recognize and track 2D images in the physical environment.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Syntax
public sealed class ARTrackedImageManager : ARTrackableManager<XRImageTrackingSubsystem, XRImageTrackingSubsystemDescriptor, XRTrackedImage, ARTrackedImage>
Properties
gameObjectName
The name to be used for the GameObject whenever a new image is detected.
Declaration
protected override string gameObjectName { get; }
Property Value
| Type | Description |
|---|---|
| String |
Overrides
maxNumberOfMovingImages
The maximum number of moving images to track in realtime. Support may vary between devices and providers. Check
for support at runtime with .SubsystemDescriptor.supportsMovingImages.
Declaration
public int maxNumberOfMovingImages { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the subsystem does not support moving images. |
referenceLibrary
Get or set the reference image library, the set of images to search for in the physical environment.
Declaration
public IReferenceImageLibrary referenceLibrary { get; set; }
Property Value
| Type | Description |
|---|---|
| IReferenceImageLibrary |
Remarks
An IReferenceImageLibrary can be either an XRReferenceImageLibrary
or a RuntimeReferenceImageLibrary. XRReferenceImageLibrarys can only be
constructed at edit-time and are immutable at runtime. A RuntimeReferenceImageLibrary
is the runtime representation of a XRReferenceImageLibrary and may be mutable
at runtime (see MutableRuntimeReferenceImageLibrary).
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the referenceLibrary is set to |
trackedImagePrefab
If not null, instantiates this prefab for each detected image.
Declaration
public GameObject trackedImagePrefab { get; set; }
Property Value
| Type | Description |
|---|---|
| GameObject |
Methods
CreateRuntimeLibrary(XRReferenceImageLibrary)
Creates a UnityEngine.XR.ARSubsystems.RuntimeReferenceImageLibrary from an existing
UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary
or an empty library if serializedLibrary is null.
Use this to construct reference image libraries at runtime. If the library is of type
MutableRuntimeReferenceImageLibrary, it is modifiable at runtime.
Declaration
public RuntimeReferenceImageLibrary CreateRuntimeLibrary(XRReferenceImageLibrary serializedLibrary = null)
Parameters
| Type | Name | Description |
|---|---|---|
| XRReferenceImageLibrary | serializedLibrary | An existing |
Returns
| Type | Description |
|---|---|
| RuntimeReferenceImageLibrary | A new |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if there is no subsystem. This usually means image tracking is not supported. |
GetPrefab()
Declaration
protected override GameObject GetPrefab()
Returns
| Type | Description |
|---|---|
| GameObject |
Overrides
OnAfterSetSessionRelativeData(ARTrackedImage, XRTrackedImage)
Declaration
protected override void OnAfterSetSessionRelativeData(ARTrackedImage image, XRTrackedImage sessionRelativeData)
Parameters
| Type | Name | Description |
|---|---|---|
| ARTrackedImage | image | |
| XRTrackedImage | sessionRelativeData |
Overrides
OnBeforeStart()
Sets the image library on the subsystem before Start() is called on the XRImageTrackingSubsystem.
Declaration
protected override void OnBeforeStart()
Overrides
OnTrackablesChanged(List<ARTrackedImage>, List<ARTrackedImage>, List<ARTrackedImage>)
Invokes the trackedImagesChanged event.
Declaration
protected override void OnTrackablesChanged(List<ARTrackedImage> added, List<ARTrackedImage> updated, List<ARTrackedImage> removed)
Parameters
| Type | Name | Description |
|---|---|---|
| List<ARTrackedImage> | added | A list of images added this frame. |
| List<ARTrackedImage> | updated | A list of images updated this frame. |
| List<ARTrackedImage> | removed | A list of images removed this frame. |
Overrides
Events
trackedImagesChanged
Invoked once per frame with information about the ARTrackedImages that have changed, i.e., been added, updated, or removed.
This happens just before ARTrackedImages are destroyed, so you can set ARTrackedImage.destroyOnRemoval to false
from this event to suppress this behavior.
Declaration
public event Action<ARTrackedImagesChangedEventArgs> trackedImagesChanged
Event Type
| Type | Description |
|---|---|
| Action<ARTrackedImagesChangedEventArgs> |