API reference
API reference
Select your platform
No SDKs available
No versions available

OVRSpatialAnchor Class

Extends MonoBehaviour
Represents a spatial anchor.
A spatial anchor tracks a real-world pose and provides world-locking capability for virtual content. Read more at Spatial Anchor Overview.
This component can be used in two ways: to create a new spatial anchor or to bind to an existing spatial anchor.
To create a new spatial anchor, simply add this component to any GameObject. The transform of the GameObject is used to create a new spatial anchor in the Meta Quest Runtime. Afterwards, the GameObject's transform will be updated automatically. The creation operation is asynchronous, and, if it fails, this component will be destroyed.
Example:
async void CreateSpatialAnchor(GameObject gameObject) {
  // Add the component to a GameObject
  var anchor = gameObject.AddComponent<OVRSpatialAnchor>();

  // Wait for creation+localization
  await anchor.WhenLocalizedAsync();

  // Anchor is ready to use
  Debug.Log($"Anchor created at {anchor.transform.position}");
}

Properties

Created : bool
[Get]
Whether the spatial anchor is created.
Creation is asynchronous and may take several frames. If creation fails, the component is destroyed.
Signature
bool Created
IsTracked : bool
[Get]
Whether this anchor is current considered tracked.
An anchor may become temporarily untracked if, for example, it cannot be seen by the device.
Signature
bool IsTracked
Localized : bool
[Get]
Whether the spatial anchor is localized.
When you create a new spatial anchor, it may take a few frames before it is localized. Once localized, its transform updates automatically.
Signature
bool Localized
OnLocalize : Action< OperationResult >
Event that is dispatched when the anchor is localized.
If the anchor is already localized when a subscriber is added, the subscriber is invoked immediately.
Consider WhenLocalizedAsync for a more flexible way to await anchor localization.
Signature
Action<OperationResult> OnLocalize
PendingCreation : bool
[Get]
Checks whether the spatial anchor is pending creation.
Signature
bool PendingCreation
Space : OVRSpace
[Get]
(Obsolete) The space associated with the spatial anchor.
DeprecatedThis property is obsolete. This class provides all spatial anchor functionality and it should not be necessary to use this low-level handle directly. See SaveAsync(), ShareAsync(OVRSpaceUser), and EraseAsync().
The OVRSpace represents the runtime instance of the spatial anchor and will change across different sessions.
Signature
OVRSpace Space
Uuid : Guid
[Get]
The UUID associated with the spatial anchor.
UUIDs persist across sessions. If you load a persisted anchor, you can use the UUID to identify it.
Signature
Guid Uuid

Methods

Erase ( onComplete )
(Obsolete) Erases the OVRSpatialAnchor from persistent storage.
DeprecatedThis method is obsolete. Use EraseAsync(). To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor.
Signature
void Erase(Action< OVRSpatialAnchor, bool > onComplete=null)
Parameters
onComplete: Action< OVRSpatialAnchor, bool >  Invoked when the erase operation completes. May be null. Parameters are
  • OVRSpatialAnchor: The anchor being erased.
  • bool: A value indicating whether the erase operation succeeded.
Returns
void
Erase ( eraseOptions , onComplete )
(Obsolete) Erases the OVRSpatialAnchor from specified storage.
DeprecatedThis method is obsolete. Use EraseAsync(EraseOptions). To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor.
Signature
void Erase(EraseOptions eraseOptions, Action< OVRSpatialAnchor, bool > onComplete=null)
Parameters
eraseOptions: EraseOptions  Options how the anchor should be erased.
onComplete: Action< OVRSpatialAnchor, bool >  Invoked when the erase operation completes. May be null. Parameters are
  • OVRSpatialAnchor: The anchor being erased.
  • bool: A value indicating whether the erase operation succeeded.
Returns
void
EraseAnchorAsync ()
Erase the anchor from persistent storage.
This operation is asynchronous. Use the returned OVRTask to track the result of the asynchronous operation.
NOTE: If you have a collection of anchors to save, it is more efficient to use EraseAnchorsAsync.
Signature
OVRTask< OVRResult< OVRAnchor.EraseResult > > EraseAnchorAsync()
Returns
OVRTask< OVRResult< OVRAnchor.EraseResult > >  Returns an awaitable OVRTask representing the asynchronous erase operation.
EraseAsync ()
(Obsolete) Erases the OVRSpatialAnchor from specified storage.
DeprecatedThis method is obsolete. Use EraseAnchorAsync instead.
This method is asynchronous; use the returned OVRTask to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor.
Signature
OVRTask< bool > EraseAsync()
Returns
OVRTask< bool >  Returns an OVRTask<bool> indicating the success of the erase operation.
EraseAsync ( eraseOptions )
(Obsolete) Erases the OVRSpatialAnchor from specified storage.
DeprecatedThis method is obsolete. Use EraseAnchorAsync instead.
This method is asynchronous; use the returned OVRTask to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor.
Signature
OVRTask< bool > EraseAsync(EraseOptions eraseOptions)
Parameters
eraseOptions: EraseOptions  Options for how the anchor should be erased.
Returns
OVRTask< bool >  Returns an OVRTask<bool> indicating the success of the erase operation.
InitializeFromExisting ( space , uuid )
(Obsolete) Initializes this component from an existing space handle and uuid, for example, the result of a call to OVRPlugin.QuerySpaces.
DeprecatedThis method is obsolete. To create a new anchor, use
AddComponent<OVRSpatialAnchor>()
. To load a previously saved anchor, use LoadUnboundAnchorsAsync.
This method associates the component with an existing spatial anchor, for example, the one that was saved in a previous session. Do not call this method to create a new spatial anchor.
If you call this method, you must do so prior to the component's Start method. You cannot change the spatial anchor associated with this component after that.
Signature
void InitializeFromExisting(OVRSpace space, Guid uuid)
Parameters
space: OVRSpace  The existing OVRSpace to associate with this spatial anchor.
uuid: Guid  The universally unique identifier to associate with this spatial anchor.
Returns
void
Throws
InvalidOperationException  Thrown if Start has already been called on this component. ArgumentException  Thrown if space is not OVRSpace.Valid.
Save ( onComplete )
(Obsolete) Saves the OVRSpatialAnchor to local persistent storage.
DeprecatedThis method is obsolete. Use SaveAsync() instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion.
When saved, an OVRSpatialAnchor can be loaded by a different session. Use the Uuid to identify the same OVRSpatialAnchor at a future time.
This operation fully succeeds or fails, which means, either all anchors are successfully saved, or the operation fails.
Signature
void Save(Action< OVRSpatialAnchor, bool > onComplete=null)
Parameters
onComplete: Action< OVRSpatialAnchor, bool >  Invoked when the save operation completes. May be null. Parameters are
  • OVRSpatialAnchor: The anchor being saved.
  • bool: A value indicating whether the save operation succeeded.
Returns
void
Save ( saveOptions , onComplete )
(Obsolete) Saves the OVRSpatialAnchor with specified SaveOptions.
DeprecatedThis method is obsolete. Use SaveAsync() instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion. When saved, the OVRSpatialAnchor can be loaded by a different session. Use the Uuid to identify the same OVRSpatialAnchor at a future time.
This operation fully succeeds or fails; that is, either all anchors are successfully saved, or the operation fails.
Signature
void Save(SaveOptions saveOptions, Action< OVRSpatialAnchor, bool > onComplete=null)
Parameters
saveOptions: SaveOptions  Save options, e.g., whether local or cloud.
onComplete: Action< OVRSpatialAnchor, bool >  Invoked when the save operation completes. May be null. Parameters are
  • OVRSpatialAnchor: The anchor being saved.
  • bool: A value indicating whether the save operation succeeded.
Returns
void
SaveAnchorAsync ()
Saves this anchor to persistent storage.
This operation is asynchronous. Use the returned OVRTask to track the result of the asynchronous operation.
When saved, an OVRSpatialAnchor can be loaded by a different session. Use the Uuid to identify the same OVRSpatialAnchor at a future time.
NOTE: If you have a collection of anchors to save, it is more efficient to use SaveAnchorsAsync.
Signature
OVRTask< OVRResult< OVRAnchor.SaveResult > > SaveAnchorAsync()
Returns
OVRTask< OVRResult< OVRAnchor.SaveResult > >  Returns an awaitable OVRTask representing the asynchronous save operation.
SaveAsync ()
(Obsolete) Saves the OVRSpatialAnchor with specified SaveOptions.
DeprecatedThis method is obsolete. Use SaveAnchorAsync instead.
This method is asynchronous; use the returned OVRTask to be notified of completion. When saved, the OVRSpatialAnchor can be loaded by a different session. Use the Uuid to identify the same OVRSpatialAnchor at a future time.
This operation fully succeeds or fails; that is, either all anchors are successfully saved, or the operation fails.
Signature
OVRTask< bool > SaveAsync()
Returns
OVRTask< bool >  Returns an OVRTask<bool> indicating the success of the save operation.
SaveAsync ( saveOptions )
(Obsolete) Saves the OVRSpatialAnchor with specified SaveOptions.
DeprecatedThis method is obsolete. Use SaveAnchorAsync instead.
This method is asynchronous; use the returned OVRTask to be notified of completion. When saved, the OVRSpatialAnchor can be loaded by a different session. Use the Uuid to identify the same OVRSpatialAnchor at a future time.
This operation fully succeeds or fails; that is, either all anchors are successfully saved, or the operation fails.
Signature
OVRTask< bool > SaveAsync(SaveOptions saveOptions)
Parameters
saveOptions: SaveOptions  Options for how the anchor will be saved.
Returns
OVRTask< bool >  Returns an OVRTask<bool> indicating the success of the save operation.
Share ( user , onComplete )
(Obsolete) Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.
DeprecatedThis method is obsolete. Use ShareAsync(OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion.
Signature
void Share(OVRSpaceUser user, Action< OperationResult > onComplete=null)
Parameters
user: OVRSpaceUser  An Oculus user to share the anchor with.
onComplete: Action< OperationResult >  Invoked when the share operation completes. May be null. Delegate parameter is
  • OperationResult: An error code that indicates whether the share operation succeeded or not.
Returns
void
Share ( user1 , user2 , onComplete )
(Obsolete) Shares the anchor with two OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
DeprecatedThis method is obsolete. Use ShareAsync(OVRSpaceUser, OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion.
Signature
void Share(OVRSpaceUser user1, OVRSpaceUser user2, Action< OperationResult > onComplete=null)
Parameters
user1: OVRSpaceUser  An Oculus user to share the anchor with.
user2: OVRSpaceUser  An Oculus user to share the anchor with.
onComplete: Action< OperationResult >  Invoked when the share operation completes. May be null. Delegate parameter is
  • OperationResult: An error code that indicates whether the share operation succeeded or not.
Returns
void
Share ( user1 , user2 , user3 , onComplete )
(Obsolete) Shares the anchor with three OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
DeprecatedThis method is obsolete. Use ShareAsync(OVRSpaceUser, OVRSpaceUser, OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion.
Signature
void Share(OVRSpaceUser user1, OVRSpaceUser user2, OVRSpaceUser user3, Action< OperationResult > onComplete=null)
Parameters
user1: OVRSpaceUser  An Oculus user to share the anchor with.
user2: OVRSpaceUser  An Oculus user to share the anchor with.
user3: OVRSpaceUser  An Oculus user to share the anchor with.
onComplete: Action< OperationResult >  Invoked when the share operation completes. May be null. Delegate parameter is
  • OperationResult: An error code that indicates whether the share operation succeeded or not.
Returns
void
Share ( user1 , user2 , user3 , user4 , onComplete )
(Obsolete) Shares the anchor with four OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
DeprecatedThis method is obsolete. Use ShareAsync(OVRSpaceUser, OVRSpaceUser, OVRSpaceUser, OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion.
Signature
void Share(OVRSpaceUser user1, OVRSpaceUser user2, OVRSpaceUser user3, OVRSpaceUser user4, Action< OperationResult > onComplete=null)
Parameters
user1: OVRSpaceUser  An Oculus user to share the anchor with.
user2: OVRSpaceUser  An Oculus user to share the anchor with.
user3: OVRSpaceUser  An Oculus user to share the anchor with.
user4: OVRSpaceUser  An Oculus user to share the anchor with.
onComplete: Action< OperationResult >  Invoked when the share operation completes. May be null. Delegate parameter is
  • OperationResult: An error code that indicates whether the share operation succeeded or not.
Returns
void
Share ( users , onComplete )
(Obsolete) Shares the anchor to a collection of OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
DeprecatedThis method is obsolete. Use ShareAsync(IEnumerable<OVRSpaceUser>). To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion.
Signature
void Share(IEnumerable< OVRSpaceUser > users, Action< OperationResult > onComplete=null)
Parameters
users: IEnumerable< OVRSpaceUser >  A collection of Oculus users to share the anchor with.
onComplete: Action< OperationResult >  Invoked when the share operation completes. May be null. Delegate parameter is
  • OperationResult: An error code that indicates whether the share operation succeeded or not.
Returns
void
ShareAsync ( user )
Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.
This method is asynchronous; use the returned OVRTask to be notified of completion.
Signature
OVRTask< OperationResult > ShareAsync(OVRSpaceUser user)
Parameters
user: OVRSpaceUser  An Oculus user to share the anchor with.
Returns
OVRTask< OperationResult >  Returns an OVRTask<OperationResult> indicating the success of the share operation.
ShareAsync ( user1 , user2 )
Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.
This method is asynchronous; use the returned OVRTask to be notified of completion.
Signature
OVRTask< OperationResult > ShareAsync(OVRSpaceUser user1, OVRSpaceUser user2)
Parameters
user1: OVRSpaceUser  An Oculus user to share the anchor with.
user2: OVRSpaceUser  An Oculus user to share the anchor with.
Returns
OVRTask< OperationResult >  Returns an OVRTask<OperationResult> indicating the success of the share operation.
ShareAsync ( user1 , user2 , user3 )
Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.
This method is asynchronous; use the returned OVRTask to be notified of completion.
Signature
OVRTask< OperationResult > ShareAsync(OVRSpaceUser user1, OVRSpaceUser user2, OVRSpaceUser user3)
Parameters
user1: OVRSpaceUser  An Oculus user to share the anchor with.
user2: OVRSpaceUser  An Oculus user to share the anchor with.
user3: OVRSpaceUser  An Oculus user to share the anchor with.
Returns
OVRTask< OperationResult >  Returns an OVRTask<OperationResult> indicating the success of the share operation.
ShareAsync ( user1 , user2 , user3 , user4 )
Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.
This method is asynchronous; use the returned OVRTask to be notified of completion.
Signature
OVRTask< OperationResult > ShareAsync(OVRSpaceUser user1, OVRSpaceUser user2, OVRSpaceUser user3, OVRSpaceUser user4)
Parameters
user1: OVRSpaceUser  An Oculus user to share the anchor with.
user2: OVRSpaceUser  An Oculus user to share the anchor with.
user3: OVRSpaceUser  An Oculus user to share the anchor with.
user4: OVRSpaceUser  An Oculus user to share the anchor with.
Returns
OVRTask< OperationResult >  Returns an OVRTask<OperationResult> indicating the success of the share operation.
ShareAsync ( users )
Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.
This method is asynchronous; use the returned OVRTask to be notified of completion.
Signature
OVRTask< OperationResult > ShareAsync(IEnumerable< OVRSpaceUser > users)
Parameters
users: IEnumerable< OVRSpaceUser >  A collection of Oculus users to share the anchor with.
Returns
OVRTask< OperationResult >  Returns an OVRTask<OperationResult> indicating the success of the share operation.
ShareAsync ( groupUuid )
Shares this anchor with the group associated with the given UUID.
This method is asynchronous; use the returned OVRTask wrapper to be notified of completion.

The groupUuid parameter can be any valid Guid, which excludes the default value Guid, AKA Guid.Empty.
Signature
OVRTask< OVRResult< OVRAnchor.ShareResult > > ShareAsync(Guid groupUuid)
Parameters
groupUuid: Guid  A UUID of a group to share the anchors with. Anchors shared to this groupUuid can be loaded by other clients via LoadUnboundSharedAnchorsAsync(Guid,List<UnboundAnchor>).
NOTE: You may arbitrarily generate your own UUIDs (e.g. with System.Guid.NewGuid), or you may use UUIDs provided by colocation APIs such as in OVRColocationSession.
Returns
OVRTask< OVRResult< OVRAnchor.ShareResult > >  Returns an OVRResult<OVRAnchor.ShareResult> indicating the status of the share operation.
Throws
ArgumentException  Thrown if groupUuid is Guid.Empty.
WhenCreatedAsync ()
Creates an async task that completes when Created becomes true.
Anchor creation is asynchronous, and adding this component to a GameObject will start the creation operation. You can use this async method to await the creation from another async method.
This allows you to write code like this:
async Task<OVRSpatialAnchor> CreateAnchor(GameObject gameObject) {
  var anchor = gameObject.AddComponent<OVRSpatialAnchor>();
  await anchor.WhenCreatedAsync();
  return anchor;
}
Signature
async OVRTask< bool > WhenCreatedAsync()
Returns
async OVRTask< bool >  Returns a task-like object that can be used to track the completion of the creation. If creation succeeds, the result of the task is true, otherwise false.
WhenLocalizedAsync ()
Async method that completes when localization completes.
Localization occurs automatically, but the process may take some time. After creating a new OVRSpatialAnchor, you can await this method from within another async method to pause execution until the anchor has been localized.
If the localization operation has already completed, this method returns immediately.
The bool result of the returned OVRTask<bool> indicates whether localization was successful.
To create a new spatial anchor and wait until it is both created and localized, you can use code like this:
async Task<OVRSpatialAnchor> CreateAnchor(GameObject gameObject) {
  var anchor = gameObject.AddComponent<OVRSpatialAnchor>();
  await anchor.WhenLocalizedAsync();
  return anchor; // anchor is localized and ready to use
}
Signature
async OVRTask< bool > WhenLocalizedAsync()
Returns
async OVRTask< bool >  Returns a task-like object that can be used to track the completion of the asynchronous localization operation.

Static Methods

EraseAnchorsAsync ( anchors , uuids )
Erase a collection of anchors from persistent storage.
This operation is asynchronous. Use the returned OVRTask to track the result of the asynchronous operation.
Signature
static OVRTask< OVRResult< OVRAnchor.EraseResult > > EraseAnchorsAsync(IEnumerable< OVRSpatialAnchor > anchors, IEnumerable< Guid > uuids)
Parameters
anchors: IEnumerable< OVRSpatialAnchor >  (Optional) The anchors to erase
uuids: IEnumerable< Guid >  (Optional) The UUIDs to erase
Returns
OVRTask< OVRResult< OVRAnchor.EraseResult > >  Returns an awaitable OVRTask representing the asynchronous erase operation.
Throws
ArgumentException  Thrown if anchors and uuids are both null.
FromOVRAnchor ( anchor , unboundAnchor )
Create an unbound spatial anchor from an OVRAnchor.
Only spatial anchors retrieved as OVRAnchors should use this method. Using this function on system-managed scene anchors will succeed, but certain functions will not work.
Signature
static bool FromOVRAnchor(OVRAnchor anchor, out UnboundAnchor unboundAnchor)
Parameters
anchor: OVRAnchor  The OVRAnchor to create the unbound anchor for.
unboundAnchor: out UnboundAnchor  The created unboundAnchor.
Returns
bool  True if anchor is localizable and is not already bound to an OVRSpatialAnchor, otherwise false.
Throws
ArgumentNullException  Thrown if anchor is equal to OVRAnchor.Null (is default-constructed).
LoadUnboundAnchors ( options , onComplete )
(Obsolete) Performs a query for anchors with the specified options .
DeprecatedThis method is obsolete. Use LoadUnboundAnchorsAsync. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Use this method to find anchors that were previously persisted with Save(Action<OVRSpatialAnchor, bool>. The query is asynchronous; when the query completes, onComplete is invoked with an array of UnboundAnchors for which tracking may be requested.
onComplete is invoked with null.
Signature
static bool LoadUnboundAnchors(LoadOptions options, Action< UnboundAnchor[]> onComplete)
Parameters
options: LoadOptions  Options that affect the query.
onComplete: Action< UnboundAnchor[]>  A delegate invoked when the query completes. The delegate accepts one argument:
Returns
bool  Returns true if the operation could be initiated; otherwise false.
Throws
ArgumentNullException  Thrown if onComplete is null. InvalidOperationException  Thrown if LoadOptions.Uuids of options is null.
LoadUnboundAnchorsAsync ( uuids , unboundAnchors , onIncrementalResultsAvailable )
Loads up to 50 unbound anchors with specified UUIDs.
An UnboundAnchor is an anchor that exists, but that isn't managed by an OVRSpatialAnchor. Use this method to load a collection of anchors by UUID that haven't already been bound to an OVRSpatialAnchor.
In order to be loaded, the anchor must have previously been persisted, e.g., with SaveAnchorsAsync.
NOTE: This method will only process the first 50 UUIDs provided by uuids .
This method is asynchronous. The returned OVRTask completes when all results are available. However, anchors may be loaded in batches. To be notified as the results of individual batches are loaded, provide an onIncrementalResultsAvailable callback. The callback accepts two parameters:
(List<UnboundAnchor> unboundAnchors, int startingIndex)
  • unboundAnchors is a reference to the unboundAnchors parameter.
  • startingIndex is the index into unboundAnchors which contains the first newly loaded anchor in this batch.
Before the task completes, it is undefined behavior to access unboundAnchors outside of onIncrementalResultsAvailable invocations.
Note that if you bind an UnboundAnchor in the onIncrementalResultsAvailable callback, that same anchor will no longer be present in the unboundAnchors provided to future incremental results, or after the task completes. That is, an UnboundAnchor is removed from the list of unboundAnchors once it is bound.
unboundAnchors is the buffer used to store the results. This allows you to reuse the same buffer between subsequent calls. The list is cleared before any anchors are added to it.
Signature
static OVRTask< OVRResult< List< UnboundAnchor >, OVRAnchor.FetchResult > > LoadUnboundAnchorsAsync(IEnumerable< Guid > uuids, List< UnboundAnchor > unboundAnchors, Action< List< UnboundAnchor >, int > onIncrementalResultsAvailable=null)
Parameters
uuids: IEnumerable< Guid >  The UUIDs of the anchors to load.
unboundAnchors: List< UnboundAnchor >  The buffer to store the resulting unbound anchors into.
onIncrementalResultsAvailable: Action< List< UnboundAnchor >, int >  An optional callback that is invoked whenever a new batch of unbound anchors has been loaded.
Returns
OVRTask< OVRResult< List< UnboundAnchor >, OVRAnchor.FetchResult > >  A new OVRTask that completes when the loading operation completes.
Throws
ArgumentNullException  Thrown if uuids is null. ArgumentNullException  Thrown if unboundAnchors is null.
LoadUnboundAnchorsAsync ( options )
(Obsolete) Performs a query for anchors with the specified options .
DeprecatedThis method is obsolete. Use LoadUnboundAnchorsAsync(IEnumerable<Guid>,List<UnboundAnchor>,Action<List<UnboundAnchor>, int> instead.
Use this method to find anchors that were previously persisted with Save(Action<OVRSpatialAnchor, bool>. The query is asynchronous; when the query completes, the returned OVRTask will contain an array of UnboundAnchors for which tracking may be requested.
Signature
static OVRTask< UnboundAnchor[]> LoadUnboundAnchorsAsync(LoadOptions options)
Parameters
options: LoadOptions  Options that affect the query.
Returns
OVRTask< UnboundAnchor[]>  Returns an OVRTask with a T:UnboundAnchor[] type parameter containing the loaded unbound anchors.
Throws
InvalidOperationException  Thrown if LoadOptions.Uuids of options is null.
LoadUnboundSharedAnchorsAsync ( uuids , unboundAnchors )
Load anchors that have been shared with you.
Use this method to load spatial anchors that have been shared with you by another user.
This method requires access to Meta servers to query for shared anchors. This method can fail in a few ways:
  • The device cannot reach Meta servers, e.g., because there is no internet access (see OperationResult.Failure_SpaceNetworkRequestFailed)
  • The user has denied the "Share Point Cloud Data" device permission (see OperationResult.Failure_SpaceCloudStorageDisabled)
  • The application has not declared "Anchor And Space Sharing Support" (OVRManager > Quest Features > General > Anchor And Space Sharing Support)
Signature
static async OVRTask< OVRResult< List< UnboundAnchor >, OperationResult > > LoadUnboundSharedAnchorsAsync(IEnumerable< Guid > uuids, List< UnboundAnchor > unboundAnchors)
Parameters
uuids: IEnumerable< Guid >  The set of anchor UUIDs to load. These are typically sourced from your serialization and/or networking layers.
You should not attempt to load more than OVRSpaceQuery.MaxResultsForAnchors anchors per request.
The elements in this set will NOT be individually validated; you should be sure that none of them are Guid.Empty before calling this API.
unboundAnchors: List< UnboundAnchor >  A buffer to store the loaded anchors. This container is always cleared unless an exception is thrown.
Returns
async OVRTask< OVRResult< List< UnboundAnchor >, OperationResult > >  Returns an awaitable task-like object that can be used to track completion of the load operation.
Throws
ArgumentNullException  Thrown if either uuids or unboundAnchors is null.
LoadUnboundSharedAnchorsAsync ( groupUuid , unboundAnchors )
Loads all (unbound) spatial anchors shared with a group by its UUID.
This method is asynchronous. The returned OVRTask wrapper completes when all results are available.

In order to be loaded, the anchor must have previously been shared with the group, e.g., with ShareAsync(IEnumerable<OVRSpatialAnchor>, Guid). ShareAsync(IEnumerable<OVRSpatialAnchor>, IEnumerable<Guid>).

An UnboundAnchor is an anchor that exists, but that isn't yet managed by an OVRSpatialAnchor instance. To bind these anchors, create new GameObjects with an OVRSpatialAnchor component attached, and pass this component to an unbound anchor's UnboundAnchor.BindTo method.

Already-bound anchors will not appear in the resulting unboundAnchors list until subsequent app launches.
Signature
static async OVRTask< OVRResult< List< UnboundAnchor >, OperationResult > > LoadUnboundSharedAnchorsAsync(Guid groupUuid, List< UnboundAnchor > unboundAnchors)
Parameters
groupUuid: Guid  The group UUID to load any associated shared anchors from.
unboundAnchors: List< UnboundAnchor >  A non-null buffer to store the loaded anchors. This container is always cleared unless an exception is thrown.
Returns
async OVRTask< OVRResult< List< UnboundAnchor >, OperationResult > >  Returns an OVRResult<List<UnboundAnchor>,OperationResult>, which indicates the status of the load operation, as well as returning a now-populated reference to the unboundAnchors buffer list originally provided to this call.
This result's Status will be OperationResult.Failure_InvalidParameter if groupUuid is Guid.Empty.
Throws
ArgumentException  Thrown if groupUuid is Guid.Empty. ArgumentNullException  Thrown if unboundAnchors is null.
LoadUnboundSharedAnchorsAsync ( groupUuid , allowedAnchorUuids , unboundAnchors )
Loads all (unbound) spatial anchors shared with a group by its UUID.
This method is asynchronous. The returned OVRTask wrapper completes when all results are available.

In order to be loaded, the anchor must have previously been shared with the group, e.g., with ShareAsync(IEnumerable<OVRSpatialAnchor>, Guid). ShareAsync(IEnumerable<OVRSpatialAnchor>, IEnumerable<Guid>).

An UnboundAnchor is an anchor that exists, but that isn't yet managed by an OVRSpatialAnchor instance. To bind these anchors, create new GameObjects with an OVRSpatialAnchor component attached, and pass this component to an unbound anchor's UnboundAnchor.BindTo method.

Already-bound anchors will not appear in the resulting unboundAnchors list until subsequent app launches.
Signature
static async OVRTask< OVRResult< List< UnboundAnchor >, OperationResult > > LoadUnboundSharedAnchorsAsync(Guid groupUuid, IEnumerable< Guid > allowedAnchorUuids, List< UnboundAnchor > unboundAnchors)
Parameters
groupUuid: Guid  The group UUID to load any associated shared anchors from.
allowedAnchorUuids: IEnumerable< Guid >  A non-null, non-empty set of known anchor UUIDs to load from the group. They will not be loaded if:
  • they never existed
  • they've been erased from cloud storage
  • they were never shared to the given groupUuid Any anchor not specified will be omitted from the results in unboundAnchors .
    The elements in this set will NOT be individually validated; you should be sure that none of them are Guid.Empty before calling this API.
unboundAnchors: List< UnboundAnchor >  A non-null buffer to store the loaded anchors. This container is always cleared unless an exception is thrown.
Returns
async OVRTask< OVRResult< List< UnboundAnchor >, OperationResult > >  Returns an OVRResult<List<UnboundAnchor>,OperationResult>, which indicates the status of the load operation, as well as returning a now-populated reference to the unboundAnchors buffer list originally provided to this call.
This result's Status will be OperationResult.Failure_InvalidParameter if groupUuid is Guid.Empty, or allowedAnchorUuids is larger than OVRSpaceQuery.MaxResultsForAnchors.
Throws
ArgumentException  Thrown if groupUuid is Guid.Empty. ArgumentNullException  Thrown if either allowedAnchorUuids or unboundAnchors is null.
Save ( anchors , saveOptions , onComplete )
(Obsolete) Saves a collection of anchors to persistent storage.
DeprecatedThis method is obsolete. Use SaveAsync(IEnumerable<OVRSpatialAnchor>, SaveOptions) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion. When saved, an OVRSpatialAnchor can be loaded by a different session. Use the Uuid to identify the same OVRSpatialAnchor at a future time.
Signature
static void Save(ICollection< OVRSpatialAnchor > anchors, SaveOptions saveOptions, Action< ICollection< OVRSpatialAnchor >, OperationResult > onComplete=null)
Parameters
anchors: ICollection< OVRSpatialAnchor >  Collection of anchors
saveOptions: SaveOptions  Save options, e.g., whether local or cloud.
onComplete: Action< ICollection< OVRSpatialAnchor >, OperationResult >  Invoked when the save operation completes. May be null. onComplete receives two parameters:
  • ICollection<OVRSpatialAnchor>: The same collection as in anchors parameter
  • OperationResult: An error code indicating whether the save operation succeeded or not.
Returns
void
Throws
ArgumentNullException  Thrown if anchors is null.
SaveAnchorsAsync ( anchors )
Saves a collection of anchors.
This method is asynchronous; use the returned OVRTask to be notified of completion. When saved, the OVRSpatialAnchor can be loaded by a different session. Use LoadUnboundAnchorsAsync(IEnumerable<Guid>,List<UnboundAnchor>,Action<List<UnboundAnchor>,int>) to load some or all OVRSpatialAnchor at a future time.
This operation fully succeeds or fails; that is, either all anchors are successfully saved, or the operation fails.
Signature
static OVRTask< OVRResult< OVRAnchor.SaveResult > > SaveAnchorsAsync(IEnumerable< OVRSpatialAnchor > anchors)
Parameters
anchors: IEnumerable< OVRSpatialAnchor >  The anchors to save.
Returns
OVRTask< OVRResult< OVRAnchor.SaveResult > >  Returns an awaitable OVRTask representing the asynchronous save operation.
Throws
ArgumentNullException  Thrown if anchors is null.
SaveAsync ( anchors , saveOptions )
(Obsolete) Saves a collection of anchors to persistent storage.
DeprecatedThis method is obsolete. Use SaveAnchorsAsync instead.
This method is asynchronous. Use the returned OVRTask to track the progress of the save operation.
When saved, an OVRSpatialAnchor can be loaded in a different session. Use the Uuid to identify the same OVRSpatialAnchor at a future time.
Signature
static OVRTask< OperationResult > SaveAsync(IEnumerable< OVRSpatialAnchor > anchors, SaveOptions saveOptions)
Parameters
anchors: IEnumerable< OVRSpatialAnchor >  The collection of anchors to save.
saveOptions: SaveOptions  Save options, e.g., whether local or cloud.
Returns
OVRTask< OperationResult >  Returns a task that represents the asynchronous save operation.
Throws
ArgumentNullException  Thrown if anchors is null.
Share ( anchors , users , onComplete )
(Obsolete) Shares a collection of OVRSpatialAnchor to specified users.
Specified users will be able to download, track, and share specified anchors.
DeprecatedThis method is obsolete. Use ShareAsync(IEnumerable<OVRSpatialAnchor>,IEnumerable<OVRSpaceUser>) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
This method is asynchronous. Use onComplete to be notified of completion.
This operation fully succeeds or fails, which means, either all anchors are successfully shared or the operation fails.
Signature
static void Share(ICollection< OVRSpatialAnchor > anchors, ICollection< OVRSpaceUser > users, Action< ICollection< OVRSpatialAnchor >, OperationResult > onComplete=null)
Parameters
anchors: ICollection< OVRSpatialAnchor >  The collection of anchors to share.
users: ICollection< OVRSpaceUser >  An array of Oculus users to share these anchors with.
onComplete: Action< ICollection< OVRSpatialAnchor >, OperationResult >  Invoked when the share operation completes. May be null. Delegate parameter is
  • ICollection<OVRSpatialAnchor>: The collection of anchors being shared.
  • OperationResult: An error code that indicates whether the share operation succeeded or not.
Returns
void
Throws
ArgumentNullException  Thrown if anchors is null. ArgumentNullException  Thrown if users is null.
ShareAsync ( anchors , users )
Shares a collection of anchors with a collection of users.
The users will be able to download, localize, and share the specified anchors.
This method is asynchronous. Use the returned OVRTask to monitor completion.
This operation fully succeeds or fails, which means, either all anchors are successfully shared or the operation fails.
Signature
static OVRTask< OperationResult > ShareAsync(IEnumerable< OVRSpatialAnchor > anchors, IEnumerable< OVRSpaceUser > users)
Parameters
anchors: IEnumerable< OVRSpatialAnchor >  The collection of anchors to share.
users: IEnumerable< OVRSpaceUser >  An array of Oculus users to share these anchors with.
Returns
OVRTask< OperationResult >  Returns a task that can be used to track the completion of the sharing operation.
Throws
ArgumentNullException  Thrown if anchors is null. ArgumentNullException  Thrown if users is null.
ShareAsync ( anchors , groupUuid )
Shares a collection of anchors to a group.
This method is asynchronous; use the returned OVRTask wrapper to be notified of completion.

The groupUuid parameter can be any valid Guid, which excludes the default value Guid, AKA Guid.Empty.
Signature
static OVRTask< OVRResult< OVRAnchor.ShareResult > > ShareAsync(IEnumerable< OVRSpatialAnchor > anchors, Guid groupUuid)
Parameters
anchors: IEnumerable< OVRSpatialAnchor >  The collection of anchors to share. These anchors must exist, be localized, and be saved prior to sharing.
groupUuid: Guid  A UUID of a group to share the anchors with. Anchors shared to this groupUuid can be loaded by other clients via LoadUnboundSharedAnchorsAsync(Guid,List<UnboundAnchor>).
NOTE: You may arbitrarily generate your own UUIDs (e.g. with System.Guid.NewGuid), or you may use UUIDs provided by colocation APIs such as in OVRColocationSession.
Returns
OVRTask< OVRResult< OVRAnchor.ShareResult > >  Returns an OVRResult<OVRAnchor.ShareResult> indicating the status of the share operation.
Throws
ArgumentException  Thrown if groupUuid is Guid.Empty ArgumentNullException  Thrown if anchors is null.
ShareAsync ( anchors , groupUuids )
Shares a collection of anchors to a collection of groups.
This method is asynchronous; use the returned OVRTask wrapper to be notified of completion.

The groupUuids parameter can consist of any valid Guids, which excludes the default value Guid, AKA Guid.Empty.
Signature
static OVRTask< OVRResult< OVRAnchor.ShareResult > > ShareAsync(IEnumerable< OVRSpatialAnchor > anchors, IEnumerable< Guid > groupUuids)
Parameters
anchors: IEnumerable< OVRSpatialAnchor >  The collection of anchors to share. These anchors must exist, be localized, and be saved prior to sharing.
groupUuids: IEnumerable< Guid >  The collection of group UUIDs to share the anchors with. Anchors shared to these groupUuids can be loaded by other clients via LoadUnboundSharedAnchorsAsync(Guid,List<UnboundAnchor>), called individually per group UUID.
NOTE: You may arbitrarily generate your own UUIDs (e.g. with System.Guid.NewGuid), or you may use UUIDs provided by colocation APIs such as in OVRColocationSession.
Returns
OVRTask< OVRResult< OVRAnchor.ShareResult > >  Returns an OVRResult<OVRAnchor.ShareResult> indicating the status of the share operation.
Throws
ArgumentException  Thrown if groupUuids contains at least 1 Guid.Empty. ArgumentNullException  Thrown if anchors or groupUuids is null.

Inner Structs

EraseOptions Struct

(Obsolete) Represents options for erasing an OVRSpatialAnchor.
DeprecatedThis method is obsolete. You no longer need to provide a storage location when erasing an anchor.
This struct is used to provide input parameters to the following (now obsolete) methods:
  • OVRSpatialAnchor.Erase(EraseOptions,Action<OVRSpatialAnchor,bool>) and
  • OVRSpatialAnchor.EraseAsync(EraseOptions) and

Fields

(Obsolete) Location from where the OVRSpatialAnchor will be erased.
DeprecatedYou no longer need to provide a storage location when erasing anchors.
In the now obsolete methods, you could specify a storage location (local or cloud) from which to erase the anchor. This is no longer required.
Signature
OVRSpace.StorageLocation Storage

LoadOptions Struct

(Obsolete) Options for loading unbound OVRSpatialAnchors used by OVRSpatialAnchor.LoadUnboundAnchorsAsync(LoadOptions).
DeprecatedThis struct is obsolete. It is only for use with the obsolete OVRSpatialAnchor.LoadUnboundAnchorsAsync(LoadOptions). Instead, consider the newer version OVRSpatialAnchor.LoadUnboundAnchorsAsync(IEnumerable<Guid>,List<UnboundAnchor>,Action<List<UnboundAnchor>,int>).
This example shows how to create LoadOptions for loading anchors when given a set of UUIDs.
OVRSpatialAnchor.LoadOptions options = new OVRSpatialAnchor.LoadOptions
{
    Timeout = 0,
    Uuids = savedAnchorUuids
};

Static Fields

MaxSupported : const int
The maximum number of uuids that may be present in the Uuids collection.
Signature
const int MaxSupported

Properties

MaxAnchorCount : int
[Get][Set]
(Obsolete) The maximum number of anchors to query.
In prior SDK versions, it was mandatory to set this property to receive any results. However, this property is now obsolete. If MaxAnchorCount is zero, i.e., the default initialized value, it will automatically be set to the count of Uuids.
If non-zero, the number of anchors in the result will be limited to MaxAnchorCount, preserving the previous behavior.
Signature
int MaxAnchorCount
StorageLocation : OVRSpace.StorageLocation
[Get][Set]
The storage location from which to query spatial anchors.
Signature
OVRSpace.StorageLocation StorageLocation
Timeout : double
[Get][Set]
The timeout, in seconds, for the query operation.
A value of zero indicates no timeout.
Signature
double Timeout
Uuids : IReadOnlyList< Guid >
[Get][Set]
The set of spatial anchors to query, identified by their UUIDs.
The UUIDs are copied by the OVRSpatialAnchor.LoadUnboundAnchorsAsync method and no longer referenced internally afterwards.
You must supply a list of UUIDs. OVRSpatialAnchor.LoadUnboundAnchorsAsync will throw if this property is null.
Signature
IReadOnlyList<Guid> Uuids

SaveOptions Struct

(Obsolete) Represents options for saving an OVRSpatialAnchor.
DeprecatedThis method is obsolete. You no longer need to provide a storage location when saving anchors.
This struct is used to provide input parameters to the following (now obsolete) methods:
  • OVRSpatialAnchor.Save(SaveOptions,Action<OVRSpatialAnchor,bool>) and
  • OVRSpatialAnchor.SaveAsync(SaveOptions) and

Fields

Location where OVRSpatialAnchor will be saved.
DeprecatedYou no longer need to provide a storage location when saving an anchor.
In the now obsolete save methods, you could specify a storage location (local or cloud) from which to save the anchor. This is no longer required.
Signature
OVRSpace.StorageLocation Storage

UnboundAnchor Struct

A spatial anchor that has not been bound to an OVRSpatialAnchor.
Use this object to bind an unbound spatial anchor to an OVRSpatialAnchor.

Properties

Localized : bool
[Get]
Whether the anchor has been localized.
Prior to localization, the anchor's Pose cannot be determined.
Signature
bool Localized
Localizing : bool
[Get]
Whether the anchor is in the process of being localized.
Signature
bool Localizing
Pose : Pose
[Get]
(Obsolete) The world space pose of the spatial anchor.
DeprecatedThis method is obsolete. Acquiring the pose can fail; consider TryGetPose instead.
Signature
Pose Pose
Uuid : Guid
[Get]
The universally unique identifier associated with this anchor.
Signature
Guid Uuid

Methods

BindTo ( spatialAnchor )
Binds an unbound anchor to an OVRSpatialAnchor component.
Use this to bind an unbound anchor to an OVRSpatialAnchor. After BindTo is used to bind an UnboundAnchor to an OVRSpatialAnchor, the UnboundAnchor is no longer valid; that is, it cannot be bound to another OVRSpatialAnchor.
Signature
void BindTo(OVRSpatialAnchor spatialAnchor)
Parameters
spatialAnchor: OVRSpatialAnchor  The component to which this unbound anchor should be bound. It should have been recently instantiated, ideally on the same frame as this call.
Returns
void
Throws
InvalidOperationException  Thrown if this UnboundAnchor does not refer to a valid anchor. ArgumentNullException  Thrown if spatialAnchor is null. ArgumentException  Thrown if an anchor is already bound to spatialAnchor . ArgumentException  Thrown if spatialAnchor is pending creation (see OVRSpatialAnchor.PendingCreation). InvalidOperationException  Thrown if this UnboundAnchor is already bound to an OVRSpatialAnchor.
Localize ( onComplete , timeout )
(Obsolete) Localizes an anchor.
DeprecatedThis method is obsolete. Use LocalizeAsync instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
The delegate supplied to OVRSpatialAnchor.LoadUnboundAnchors receives an array of unbound spatial anchors. You can choose whether to localize each one and be notified when localization completes.
The onComplete delegate receives two arguments:
  • bool: Whether localization was successful
  • UnboundAnchor: The anchor to bind
Upon successful localization, your delegate should instantiate an OVRSpatialAnchor, then bind the UnboundAnchor to the OVRSpatialAnchor by calling UnboundAnchor.BindTo. Once an UnboundAnchor is bound to an OVRSpatialAnchor, it cannot be used again; that is, it cannot be bound to multiple OVRSpatialAnchor components.
Signature
void Localize(Action< UnboundAnchor, bool > onComplete=null, double timeout=0)
Parameters
onComplete: Action< UnboundAnchor, bool >  A delegate invoked when localization completes (which may fail). The delegate receives two arguments:
  • UnboundAnchor: The anchor to bind
  • bool: Whether localization was successful
timeout: double  The timeout, in seconds, to attempt localization, or zero to indicate no timeout.
Returns
void
Throws
InvalidOperationException  Thrown if
  • The anchor does not support localization, e.g., because it is invalid.
  • The anchor has already been localized.
  • The anchor is being localized, e.g., because Localize was previously called.
LocalizeAsync ( timeout )
Localizes an anchor.
The delegate supplied to LoadUnboundAnchorsAsync(IEnumerable<Guid>,List<UnboundAnchor>,Action<List<UnboundAnchor>,int>) receives an array of unbound spatial anchors. You can choose whether to localize each one and be notified when localization completes.
Upon successful localization, your delegate should instantiate an OVRSpatialAnchor, then bind the UnboundAnchor to the OVRSpatialAnchor by calling UnboundAnchor.BindTo. Once an UnboundAnchor is bound to an OVRSpatialAnchor, it cannot be used again; that is, it cannot be bound to multiple OVRSpatialAnchor components.
Signature
OVRTask< bool > LocalizeAsync(double timeout=0)
Parameters
timeout: double  The timeout, in seconds, to attempt localization, or zero to indicate no timeout.
Returns
OVRTask< bool >  Returns an OVRTask<bool> indicating the success of the localization.
Throws
InvalidOperationException  Thrown if the anchor does not support localization, e.g., because it is invalid.
TryGetPose ( pose )
The world space pose of the spatial anchor.
Use this method to get the pose of the anchor after it has been localized with LocalizeAsync.
If the anchor is not localized, this method throws InvalidOperationException. If the anchor has been localized, but the pose cannot be retrieved (for example, because of a temporary tracking issue), then this method returns false, and you should try again later.
Signature
bool TryGetPose(out Pose pose)
Parameters
pose: out Pose  If this method returns true, then pose will contain the world space pose of the anchor. If this method returns false, pose is set to identity.
Returns
bool  Returns true if the pose could be obtained, otherwise false.
Throws
InvalidOperationException  Thrown if the anchor is invalid, e.g., because it has been destroyed. InvalidOperationException  Thrown if the anchor has not been localized.

Inner Enum

OperationResult Enum

Possible results of various anchor operations.
For Failure results, additional details about what went wrong may be available in the runtime logs if you are running from the Unity Editor or a Development Build.

Enumeration Constants

MemberValueDescription
Success
OVRPlugin.Result.Success
The operation succeeded.
Failure
OVRPlugin.Result.Failure
The operation failed with no additional details.
Failure_DataIsInvalid
OVRPlugin.Result.Failure_DataIsInvalid
The operation failed because the associated data is invalid.
Failure_InvalidParameter
OVRPlugin.Result.Failure_InvalidParameter
An invalid parameter was supplied to the operation, implicating early termination.
Failure_SpaceCloudStorageDisabled
OVRPlugin.Result.Failure_SpaceCloudStorageDisabled
The operation failed because saving anchors to cloud storage is not permitted by the user.
Failure_SpaceMappingInsufficient
OVRPlugin.Result.Failure_SpaceMappingInsufficient
The user was able to download the anchors, but the device was unable to localize itself in the spatial data received from the sharing device.
Failure_SpaceLocalizationFailed
OVRPlugin.Result.Failure_SpaceLocalizationFailed
The user was able to download the anchors, but the device was unable to localize them.
Failure_SpaceNetworkTimeout
OVRPlugin.Result.Failure_SpaceNetworkTimeout
Network operation timed out.
Failure_SpaceNetworkRequestFailed
OVRPlugin.Result.Failure_SpaceNetworkRequestFailed
Network operation failed.
Failure_GroupNotFound
OVRPlugin.Result.Failure_SpaceGroupNotFound
The operation failed because the Group UUID could not be found.