Anchors platform support
Anchors are supported on the ARCore, ARKit, HoloLens, Meta OpenXR, and XR Simulation platforms, as shown in the table below:
Provider plug-in | Anchors supported | Provider documentation |
---|---|---|
Google ARCore XR Plug-in | Yes | Anchors (ARCore) |
Apple ARKit XR Plug-in | Yes | Anchors (ARKit) |
Apple visionOS XR Plug-in | Yes | N/A |
HoloLens | Yes | N/A |
Unity OpenXR: Meta | Yes | Anchors (Meta OpenXR) |
XR Simulation | Yes | Anchors (XR Simulation) |
Check for support at runtime
Your app can check at runtime whether a provider plug-in supports anchors on the user's device. This is useful in situations where you are unsure if the device supports anchors, which may be the case if you are using AR Foundation with a third-party provider plug-in.
Use the following example code to check if the device supports anchors:
void Start()
{
if (LoaderUtility
.GetActiveLoader()?
.GetLoadedSubsystem<XRAnchorSubsystem>() != null)
{
// XRAnchorSubsystem was loaded. The platform supports anchors.
}
}
Note
This example code assumes that your app has already initialized XR.
By default XR initializes automatically when your app starts, but this is configurable via Project Settings > XR Plug-in Management > Initialize XR on Startup. Refer to the XR Plug-in Management End-user documentation for more detailed information about managing the XR Plug-in lifecycle.
Optional features
The following table lists the optional features of the anchor subsystem. Each optional feature is defined by a Descriptor Property of the XRAnchorSubsystemDescriptor, which you can check at runtime to determine if a feature is supported. The Description column lists the optional API that may or may not be implemented on each platform.
Tip
Check the API documentation to understand how each API behaves when the provider doesn't support a feature. For example, some methods may throw an exception if you call them when the feature isn't supported.
Feature | Descriptor Property | Description |
---|---|---|
Trackable attachments | supportsTrackableAttachments | Indicates whether the provider implementation supports the ability to attach an anchor to a trackable via TryAttachAnchor. |
Synchronous add | supportsSynchronousAdd | Indicates whether the provider implementation supports the ability to synchronously add anchors via TryAddAnchor. |
Save anchor | supportsSaveAnchor | Indicates whether the provider implementation supports the ability to persistently save anchors via TrySaveAnchorAsync. |
Load anchor | supportsLoadAnchor | Indicates whether the provider implementation supports the ability to load persistently saved anchors via TryLoadAnchorAsync. |
Erase anchor | supportsEraseAnchor | Indicates whether the provider implementation supports the ability to erase the persistent saved data associated with an anchor via TryEraseAnchorAsync. |
Get saved anchor IDs | supportsGetSavedAnchorIds | Indicates whether the provider implementation supports the ability to get all saved persistent anchor GUIDs via TryGetSavedAnchorIdsAsync. |
Async cancellation | supportsAsyncCancellation | Indicates whether the provider implementation supports cancelling async operations in progress using a CancellationToken. |
Optional features support table
To understand the optional features that are implemented in each supported XR plug-in provider, refer to the following table:
Feature | ARCore | ARKit | HoloLens | Meta OpenXR | XR Simulation |
---|---|---|---|---|---|
Trackable attachments | Yes | Yes | Yes | ||
Synchronous add | Yes | Yes | |||
Save anchor | Yes | ||||
Load anchor | Yes | ||||
Erase anchor | Yes | ||||
Get saved anchor IDs | |||||
Async cancellation |
Check for optional feature support
Your app can check at runtime whether an anchor provider supports any optional features on the user's device. The XRAnchorSubsystemDescriptor contains boolean properties for each optional feature that tell you if they are supported.
Refer to the following example code to learn how to check for optional feature support:
void CheckForOptionalFeatureSupport()
{
// This is inefficient. You should re-use a saved reference instead.
var manager = Object.FindAnyObjectByType<ARAnchorManager>();
// Use manager.descriptor to determine which optional features
// are supported on the device. For example:
if (manager.descriptor.supportsTrackableAttachments)
{
// Trackable attachments are supported.
}
}
Apple and ARKit are trademarks of Apple Inc., registered in the U.S. and other countries and regions.