Stay organized with collections
Save and categorize content based on your preferences.
ARShareableAnchorManager
A trackable manager that enables placing, tracking, saving and loading shareable anchors.
A shareable anchor is a pose (position and rotation) in the physical environment that is tracked by an XR device. It can then be saved on a host for sharing among different clients, so that each client can retrieve the same anchor from the physical environment.
Summary
Inheritance
Inherits from:
ARTrackableManager< XRShareableAnchorSubsystem, XRShareableAnchorSubsystemDescriptor, XRShareableAnchorSubsystem.Provider, XRShareableAnchor, ARShareableAnchor >
Public functions
|
GetShareableAnchor(TrackableId trackableId)
|
Gets the ARShareableAnchor with given trackableId , or null if no such anchor exists.
|
TryAddAnchor(Pose pose)
|
Attempts to create a new anchor at the given pose .
|
TryAttachGeospatialAnchor(XRGeospatialPose geospatialPose)
|
Attempts to create a shareable anchor "attached" to the given geospatial pose.
|
TryAttachSurfaceAnchorAsync(XRGeospatialSurfaceType type, XRGeospatialPose geospatialPose, CancellationToken cancellationToken)
|
Attempts to create a shareable anchor "attached" to the given geospatial pose relative to the location's surface.
|
TryEraseAnchorAsync(SerializableGuid shareableId, XRShareableAnchorHosts host, CancellationToken cancellationToken)
|
Awaitable< XRResultStatus >
Attempts to erase the persistent saved data associated with an anchor given its persistent GUID.
|
TryGetSavedAnchorIdsAsync(XRShareableAnchorHosts host, Allocator allocator, CancellationToken cancellationToken)
|
Awaitable< Result< NativeArray< SerializableGuid > > >
Attempts to get a NativeArray containing all saved persistent GUIDs from the given host.
|
TryLoadAnchorAsync(SerializableGuid shareableId, XRShareableAnchorHosts host, CancellationToken cancellationToken)
|
Attempts to load a shareable anchor given its persistent GUID.
|
TryRemoveAnchor(ARShareableAnchor anchor)
|
bool
Attempts to remove a shareable anchor.
|
TrySaveAnchorAsync(ARShareableAnchor anchor, XRShareableAnchorHosts host, CancellationToken cancellationToken)
|
Awaitable< Result< SerializableGuid > >
Attempts to persistently save the given anchor so that it can be loaded in a future session.
|
Properties
shareableAnchorPrefab
GameObject shareableAnchorPrefab
Gets or sets the prefab which is used to instantiate each ARShareableAnchor.
May be null.
The purpose of this property is to extend the functionality of ARShareableAnchors. It is not the recommended way to instantiate content associated with an ARShareableAnchor.
Public functions
GetShareableAnchor
ARShareableAnchor GetShareableAnchor(
TrackableId trackableId
)
Gets the ARShareableAnchor with given trackableId , or null if no such anchor exists.
| Details |
| Parameters |
|
|
Returns
|
|
TryAddAnchor
ARShareableAnchor TryAddAnchor(
Pose pose
)
Attempts to create a new anchor at the given pose .
| Details |
| Parameters |
pose
|
The pose, in Unity world space, of the anchor.
|
|
|
Returns
|
|
TryAttachSurfaceAnchorAsync
async Awaitable< Result< ARShareableAnchor > > TryAttachSurfaceAnchorAsync(
XRGeospatialSurfaceType type,
XRGeospatialPose geospatialPose,
CancellationToken cancellationToken
)
Attempts to create a shareable anchor "attached" to the given geospatial pose relative to the location's surface.
See also:
XRShareableAnchorSubsystemDescriptor.supportsAttachSurfaceAnchor
| Details |
| Parameters |
type
|
|
geospatialPose
|
The geospatial pose of the target location where XRGeospatialPose.Altitude represents the altitude in meters relative to the surface.
|
cancellationToken
|
|
|
| Exceptions |
OperationCanceledException
|
Thrown if the operation has been canceled either by the caller or the Unity main thread.
|
|
|
Returns
|
The result of the async operation, containing the newly added shareable anchor if the operation succeeded. The anchor will start with XRShareableAnchorHosts.Geospatial and type . You are responsible to await this result.
|
TryEraseAnchorAsync
Awaitable< XRResultStatus > TryEraseAnchorAsync(
SerializableGuid shareableId,
XRShareableAnchorHosts host,
CancellationToken cancellationToken
)
Attempts to erase the persistent saved data associated with an anchor given its persistent GUID.
See also:
XRShareableAnchorSubsystemDescriptor.supportsEraseAnchor
| Details |
| Parameters |
shareableId
|
|
host
|
The target host to erase this persistent id.
|
cancellationToken
|
|
|
| Exceptions |
OperationCanceledException
|
Thrown if the operation has been canceled either by the caller or the Unity main thread.
|
|
|
Returns
|
|
TryGetSavedAnchorIdsAsync
Awaitable< Result< NativeArray< SerializableGuid > > > TryGetSavedAnchorIdsAsync(
XRShareableAnchorHosts host,
Allocator allocator,
CancellationToken cancellationToken
)
Attempts to get a NativeArray containing all saved persistent GUIDs from the given host.
See also:
XRShareableAnchorSubsystemDescriptor.supportsGetSavedAnchorIds
| Details |
| Parameters |
host
|
The host to retrieve all saved anchors.
|
allocator
|
The allocation strategy to use for the resulting NativeArray.
|
cancellationToken
|
|
|
| Exceptions |
OperationCanceledException
|
Thrown if the operation has been canceled either by the caller or the Unity main thread.
|
|
|
Returns
|
The result of the async operation, containing a NativeArray of persistent GUIDs allocated with the given allocator if the operation succeeded. You are responsible to await this result.
|
TryLoadAnchorAsync
async Awaitable< Result< ARShareableAnchor > > TryLoadAnchorAsync(
SerializableGuid shareableId,
XRShareableAnchorHosts host,
CancellationToken cancellationToken
)
Attempts to load a shareable anchor given its persistent GUID.
See also:
XRShareableAnchorSubsystemDescriptor.supportsLoadAnchor
| Details |
| Parameters |
shareableId
|
|
host
|
The target host to load this persistent id.
|
cancellationToken
|
|
|
| Exceptions |
OperationCanceledException
|
Thrown if the operation has been canceled either by the caller or the Unity main thread.
|
|
|
Returns
|
|
TryRemoveAnchor
bool TryRemoveAnchor(
ARShareableAnchor anchor
)
Attempts to remove a shareable anchor.
| Details |
| Parameters |
|
|
Returns
|
Returns true if successful, otherwise false.
|
TrySaveAnchorAsync
Awaitable< Result< SerializableGuid > > TrySaveAnchorAsync(
ARShareableAnchor anchor,
XRShareableAnchorHosts host,
CancellationToken cancellationToken
)
Attempts to persistently save the given anchor so that it can be loaded in a future session.
Use the SerializableGuid returned by this method as an input parameter to TryLoadAnchorAsync or TryEraseAnchorAsync.
See also:
XRShareableAnchorSubsystemDescriptor.supportsSaveAnchor
| Details |
| Parameters |
anchor
|
|
host
|
The target host to save this anchor.
|
cancellationToken
|
|
|
| Exceptions |
OperationCanceledException
|
Thrown if the operation has been canceled either by the caller or the Unity main thread.
|
|
|
Returns
|
The result of the async operation, containing a new persistent GUID if the operation succeeded. If the operation failed, you may also check with XrResultExtensions.IsPersistenceResult for any persistence reasons. You are responsible to await this result.
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-10-28 UTC.
[null,null,["Last updated 2026-10-28 UTC."],[],[]]