Class XRAnchorSubsystem.Provider
An abstract class to be implemented by providers of this subsystem.
Inherited Members
Namespace: UnityEngine .XR.ARSubsystems
Assembly: Unity.XR.ARSubsystems.dll
Syntax
public abstract class XRAnchorSubsystem.Provider : SubsystemProvider<XRAnchorSubsystem>
Methods
GetChanges(XRAnchor, Allocator)
Gets a TrackableTrackableChanges
instance.
Declaration
public abstract TrackableChanges<XRAnchor> GetChanges(XRAnchor defaultAnchor, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
XRAnchor | defaultAnchor | The default anchor. You should use this to initialize the returned
Trackable |
Allocator | allocator | An |
Returns
Type | Description |
---|---|
Trackable |
The changes to anchors since the last call to this method. |
TryAddAnchor(Pose, out XRAnchor)
Attempts to create a new anchor at the given pose
.
Declaration
public virtual bool TryAddAnchor(Pose pose, out XRAnchor anchor)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | The pose, in session space, of the new anchor. |
XRAnchor | anchor | The output anchor. Valid only if this method returns true. |
Returns
See Also
TryAddAnchorAsync(Pose)
Attempts to create a new anchor at the given pose
.
Declaration
public virtual Awaitable<Result<XRAnchor>> TryAddAnchorAsync(Pose pose)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | The pose, in session space, of the new anchor. |
Returns
Type | Description |
---|---|
Awaitable<Result<XRAnchor>> | The result of the async operation, containing the newly added anchor if the operation succeeded. You are responsible to await this result. |
Remarks
The default implementation of this method will attempt to create and return a result using
the class's implementation of Try
TryAttachAnchor(TrackableId, Pose, out XRAnchor)
Attempts to create a new anchor "attached" to the trackable with id trackableToAffix
.
The behavior of the anchor depends on the type of trackable to which this anchor is attached.
Declaration
public virtual bool TryAttachAnchor(TrackableId trackableToAffix, Pose pose, out XRAnchor anchor)
Parameters
Type | Name | Description |
---|---|---|
Trackable |
trackableToAffix | The id of the trackable to which to attach. |
Pose | pose | The pose, in session space, of the anchor to create. |
XRAnchor | anchor | The new anchor. Only valid if this method returns true. |
Returns
TryEraseAnchorAsync(SerializableGuid, CancellationToken)
Attempts to erase the persistent saved data associated with an anchor given its persistent anchor GUID.
Declaration
public virtual Awaitable<XRResultStatus> TryEraseAnchorAsync(SerializableGuid savedAnchorGuid, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Serializable |
savedAnchorGuid | A persistent anchor GUID created by Try |
Cancellation |
cancellationToken | An optional |
Returns
Type | Description |
---|---|
Awaitable<XRResult |
The result of the async operation. You are responsible to await this result. |
See Also
TryGetSavedAnchorIdsAsync(Allocator, CancellationToken)
Attempts to get a NativeArray
containing all saved persistent anchor GUIDs.
Declaration
public virtual Awaitable<Result<NativeArray<SerializableGuid>>> TryGetSavedAnchorIdsAsync(Allocator allocator, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Allocator | allocator | The allocation strategy to use for the resulting |
Cancellation |
cancellationToken | An optional |
Returns
Type | Description |
---|---|
Awaitable<Result<Native |
The result of the async operation, containing a |
See Also
TryLoadAnchorAsync(SerializableGuid, CancellationToken)
Attempts to load an anchor given its persistent anchor GUID.
Declaration
public virtual Awaitable<Result<XRAnchor>> TryLoadAnchorAsync(SerializableGuid savedAnchorGuid, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Serializable |
savedAnchorGuid | A persistent anchor GUID created by Try |
Cancellation |
cancellationToken | An optional |
Returns
Type | Description |
---|---|
Awaitable<Result<XRAnchor>> | The result of the async operation, containing the newly added anchor if the operation succeeded. You are responsible to await this result. |
See Also
TryRemoveAnchor(TrackableId)
Attempts to remove an existing anchor with TrackableanchorId
.
Declaration
public virtual bool TryRemoveAnchor(TrackableId anchorId)
Parameters
Type | Name | Description |
---|---|---|
Trackable |
anchorId | The id of an existing anchor to remove. |
Returns
TrySaveAnchorAsync(TrackableId, CancellationToken)
Attempts to persistently save the given anchor so that it can be loaded in a future AR session. Use the
SerializableGuid
returned by this method as an input parameter to Try
Declaration
public virtual Awaitable<Result<SerializableGuid>> TrySaveAnchorAsync(TrackableId anchorId, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Trackable |
anchorId | The TrackableId of the anchor to save. |
Cancellation |
cancellationToken | An optional |
Returns
Type | Description |
---|---|
Awaitable<Result<Serializable |
The result of the async operation, containing a new persistent anchor GUID if the operation succeeded. You are responsible to await this result. |