Class XRAnchorStore
Provides access to the underlying Microsoft SpatialAnchorStore
allowing a user to persist, reload, track and unpersist anchors between the SpatialAnchorStore
and the a curerntly running instance of
The SpatialAnchorStore contains a snapshot of the data at the time of it's creation. If you update the store outside of the running application then you will need to make sure to destroy and recreate this.
Getting an instance of this class will allocate an instance of the SpatialAnchorStore and retain it. You must dispose of this allocted resource or you may leak memory.
Namespace: UnityEngine.XR.WindowsMR
Syntax
public sealed class XRAnchorStore : IDisposable
Properties
PersistedAnchorNames
Retrieve all the currently stored, named anchors from the SpatialAnchorStore
If the list of names is not alrady created, we will as the anchor store for the current list of persisted names. This list will not change unless you modify the store by calling Clear(), TryPersistAnchor(TrackableId, String), UnpersistAnchor(String), or destroyong and re-creating an instance of XRAnchorStore.
Has no impact on the set of currently tracked anchors in
the running instance of
Declaration
public IReadOnlyList<string> PersistedAnchorNames { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<String> | Read only list of anchor names previously persisted to the store. |
Methods
Clear()
Clear all anchors from the store.
Has no impact on the set of currently tracked anchors in
the running instance of
Declaration
public void Clear()
Dispose()
Declaration
public void Dispose()
Finalize()
Declaration
protected void Finalize()
LoadAnchor(String)
Take a persisted anchor from the SpatialAnchorStore
with the given name and addes it to the current set of tracked
Declaration
public TrackableId LoadAnchor(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the anchor to load. |
Returns
Type | Description |
---|---|
TrackableId | The Id of the anchor. |
TryPersistAnchor(TrackableId, String)
Given a trackable anchor with id, save the anchor to the SpatialAnchorStore with the given name.
Has no impact on the set of currently tracked anchors in
the running instance of
Declaration
public bool TryPersistAnchor(TrackableId id, string name)
Parameters
Type | Name | Description |
---|---|---|
TrackableId | id | The trackable id of a |
String | name | The name you wish to assign to the anchor persisted in the SpatialAnchorStore. |
Returns
Type | Description |
---|---|
Boolean | False if there is no running instance of |
UnpersistAnchor(String)
Given an anchor with id and name, remove the anchor from the SpatialAnchorStore.
Has no impact on the set of currently tracked anchors in
the running instance of
Declaration
public void UnpersistAnchor(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of a currently persisted anchor to remove from the SpatialAnchorStore. |