Anchors platform support
The AR Foundation XRAnchorSubsystem is supported on the following platforms:
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) |
Unity OpenXR: Android XR | Yes | Anchors (Android XR) |
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 whether a feature is supported. Refer to Check for optional feature support for a code example to check whether a feature is supported.
Tip
Check the API documentation to understand how each API behaves when the provider doesn't support a feature. For example, some properties throw an exception if you try to set the value 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
The following table lists whether certain XR plug-in providers support each optional feature:
Feature | ARCore | ARKit | visionOS | HoloLens | OpenXR Meta | Android XR | XR Simulation |
---|---|---|---|---|---|---|---|
Trackable attachments | Yes | Yes | Yes | Yes | |||
Synchronous add | Yes | Yes | Yes | ||||
Save anchor | Yes | Yes | Yes | ||||
Load anchor | Yes | Yes | Yes | ||||
Erase anchor | Yes | Yes | |||||
Get saved anchor IDs | Yes | ||||||
Async cancellation | Yes |
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(ARAnchorManager manager)
{
// 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.