Class XRImageTrackingSubsystem
A subsystem for detecting and tracking a preconfigured set of images in the environment.
Inheritance
Implements
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Assembly: Unity.XR.ARSubsystems.dll
Syntax
public class XRImageTrackingSubsystem : TrackingSubsystem<XRTrackedImage, XRImageTrackingSubsystem, XRImageTrackingSubsystemDescriptor, XRImageTrackingSubsystem.Provider>, ISubsystem
Constructors
XRImageTrackingSubsystem()
Constructs a subsystem. Do not invoke directly; call Create on the XRImageTrackingSubsystemDescriptor instead.
Declaration
public XRImageTrackingSubsystem()
Properties
currentMaxNumberOfMovingImages
The current maximum number of moving images to track. This can be different from requestedMaxNumberOfMovingImages.
Declaration
public int currentMaxNumberOfMovingImages { get; }
Property Value
| Type | Description |
|---|---|
| int |
imageLibrary
Get or set the reference image library. This is the set of images to look for in the environment.
Declaration
public RuntimeReferenceImageLibrary imageLibrary { get; set; }
Property Value
| Type | Description |
|---|---|
| RuntimeReferenceImageLibrary |
Remarks
A RuntimeReferenceImageLibrary is created at runtime. Depending on the provider, it might be mutable (a MutableRuntimeReferenceImageLibrary) or immutable after creation. You can create a RuntimeReferenceImageLibrary from an XRReferenceImageLibrary using TryCreateRuntimeLibraryAsync(XRReferenceImageLibrary, CancellationToken). The synchronous CreateRuntimeLibrary(XRReferenceImageLibrary) method is deprecated as of AR Foundation 6.7.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the subsystem has been started, and you attempt to set the image library to null. |
See Also
requestedMaxNumberOfMovingImages
The requested maximum number of moving images to track.
Declaration
public int requestedMaxNumberOfMovingImages { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if the subsystem does not support tracking moving images. Check for support of this feature with supportsMovingImages. |
Methods
CreateRuntimeLibrary(XRReferenceImageLibrary)
Creates a RuntimeReferenceImageLibrary from an existing XRReferenceImageLibrary,
or an empty library if serializedLibrary is null.
Use this to construct the runtime representation of an XRReferenceImageLibrary.
Declaration
[Obsolete("CreateRuntimeLibrary is deprecated in AR Foundation 6.7. Use TryCreateRuntimeLibraryAsync instead.")]
public RuntimeReferenceImageLibrary CreateRuntimeLibrary(XRReferenceImageLibrary serializedLibrary)
Parameters
| Type | Name | Description |
|---|---|---|
| XRReferenceImageLibrary | serializedLibrary | An existing XRReferenceImageLibrary, or |
Returns
| Type | Description |
|---|---|
| RuntimeReferenceImageLibrary | A new RuntimeReferenceImageLibrary representing the deserialized version of |
Remarks
If the subsystem supports runtime mutable libraries (see supportsMutableLibrary), then the returned library will be a MutableRuntimeReferenceImageLibrary.
See Also
GetChanges(Allocator)
Retrieve the changes in the state of tracked images (added, updated, and removed) since the last call to GetChanges.
Declaration
public override TrackableChanges<XRTrackedImage> GetChanges(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | The allocator to use for the returned set of changes. |
Returns
| Type | Description |
|---|---|
| TrackableChanges<XRTrackedImage> | The set of tracked image changes (added, updated, and removed) since the last call to this method. |
Overrides
OnStart()
Starts the subsystem, that is, starts detecting images in the scene. imageLibrary must not be null.
Declaration
protected override void OnStart()
Overrides
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if imageLibrary is null. |
OnStop()
Stops the subsystem, that is, stops detecting and tracking images.
Declaration
protected override sealed void OnStop()
Overrides
TryCreateRuntimeLibraryAsync(XRReferenceImageLibrary, CancellationToken)
Asynchronously creates a RuntimeReferenceImageLibrary from an existing
XRReferenceImageLibrary, or an empty library if serializedLibrary is null.
Declaration
public Awaitable<Result<RuntimeReferenceImageLibrary>> TryCreateRuntimeLibraryAsync(XRReferenceImageLibrary serializedLibrary, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| XRReferenceImageLibrary | serializedLibrary | An existing XRReferenceImageLibrary, or |
| CancellationToken | cancellationToken | A cancellation token, which you can use to cancel the operation in progress. |
Returns
| Type | Description |
|---|---|
| Awaitable<Result<RuntimeReferenceImageLibrary>> | The result of the async operation containing the new RuntimeReferenceImageLibrary. |
Remarks
A provider can limit the number of simultaneous calls to this method. If that limit is
reached, subsequent calls fail with LimitReached
until an operation completes. Use cancellationToken to cancel an operation in progress.
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown if the provider doesn't implement TryCreateRuntimeLibraryAsync(XRReferenceImageLibrary, CancellationToken). |
| OperationCanceledException | Thrown if the operation is canceled by
|