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

OVRSpatialAnchor Class

Extends MonoBehaviour
Represents a spatial anchor.
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 Oculus Runtime. Afterwards, the GameObject's transform will be updated automatically. The creation operation is asynchronous, and, if it fails, this component will be destroyed.

Member Enumerations

Enumeration OperationResult

Possible results of operations related to anchor sharing.
Success
Operation succeeded.
Failure
Operation failed.
Failure_DataIsInvalid
Invalid data.
Failure_SpaceCloudStorageDisabled
Saving anchors to cloud storage is not permitted by the user.
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
The user was able to download the anchors, but the device was unable to localize them.
Failure_SpaceNetworkTimeout
Network operation timed out.
Failure_SpaceNetworkRequestFailed
Network operation failed.

Properties

OVRAnchor _anchor[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.
Checks whether the spatial anchor is created.
Creation is asynchronous and may take several frames. If creation fails, the component is destroyed.
Checks whether the spatial anchor is pending creation.
Checks 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.
The space associated with the spatial anchor.
NOTE: This 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.

Events

Event that is dispatched when the localization process finishes.

Member Functions

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<TResult> to be notified of completion.
Parameters
user
An Oculus user to share the anchor with.
Returns
An OVRTask<TResult> with a OperationResult type parameter indicating the success of the share operation.
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<TResult> to be notified of completion.
Parameters
user1
An Oculus user to share the anchor with.
user2
An Oculus user to share the anchor with.
Returns
An OVRTask<TResult> with a OperationResult type parameter indicating the success of the share operation.
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<TResult> to be notified of completion.
Parameters
user1
An Oculus user to share the anchor with.
user2
An Oculus user to share the anchor with.
user3
An Oculus user to share the anchor with.
Returns
An OVRTask<TResult> with a OperationResult type parameter indicating the success of the share operation.
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<TResult> to be notified of completion.
Parameters
user1
An Oculus user to share the anchor with.
user2
An Oculus user to share the anchor with.
user3
An Oculus user to share the anchor with.
user4
An Oculus user to share the anchor with.
Returns
An OVRTask<TResult> with a OperationResult type parameter indicating the success of the share operation.
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<TResult> to be notified of completion.
Parameters
users
A collection of Oculus users to share the anchor with.
Returns
An OVRTask<TResult> with a OperationResult type parameter indicating the success of the share operation.
Saves this anchor to persistent storage.
This operation is asynchronous. Use the returned OVRTask<TResult> 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.
Returns
An awaitable OVRTask<TResult> representing the asynchronous save operation.
Erase the anchor from persistent storage.
This operation is asynchronous. Use the returned OVRTask<TResult> 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.
Returns
An awaitable OVRTask<TResult> representing the asynchronous erase operation.
(Obsolete) Initializes this component from an existing space handle and uuid, e.g., the result of a call to OVRPlugin.QuerySpaces.
Deprecated
This 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.
Parameters
space
The existing OVRSpace to associate with this spatial anchor.
uuid
The universally unique identifier to associate with this spatial anchor.
Exceptions
InvalidOperationException
Thrown if Start has already been called on this component.
ArgumentException
Thrown if space is not OVRSpace.Valid.
(Obsolete) Saves the OVRSpatialAnchor to local persistent storage.
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. Deprecated
This method is obsolete. Use SaveAsync() instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
onComplete
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.
(Obsolete) Saves the OVRSpatialAnchor with specified SaveOptions.
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. Deprecated
This method is obsolete. Use SaveAsync() instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
saveOptions
Save options, e.g., whether local or cloud.
onComplete
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.
(Obsolete) Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.This method is asynchronous. Use onComplete to be notified of completion. Deprecated
This method is obsolete. Use ShareAsync(OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
user
An Oculus user to share the anchor with.
onComplete
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.
(Obsolete) Shares the anchor with two OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.This method is asynchronous. Use onComplete to be notified of completion. Deprecated
This method is obsolete. Use ShareAsync(OVRSpaceUser, OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
user1
An Oculus user to share the anchor with.
user2
An Oculus user to share the anchor with.
onComplete
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.
(Obsolete) Shares the anchor with three OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.This method is asynchronous. Use onComplete to be notified of completion. Deprecated
This method is obsolete. Use ShareAsync(OVRSpaceUser, OVRSpaceUser, OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
user1
An Oculus user to share the anchor with.
user2
An Oculus user to share the anchor with.
user3
An Oculus user to share the anchor with.
onComplete
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.
(Obsolete) Shares the anchor with four OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.This method is asynchronous. Use onComplete to be notified of completion. Deprecated
This method is obsolete. Use ShareAsync(OVRSpaceUser, OVRSpaceUser, OVRSpaceUser, OVRSpaceUser) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
user1
An Oculus user to share the anchor with.
user2
An Oculus user to share the anchor with.
user3
An Oculus user to share the anchor with.
user4
An Oculus user to share the anchor with.
onComplete
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.
(Obsolete) Shares the anchor to a collection of OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.This method is asynchronous. Use onComplete to be notified of completion. Deprecated
This method is obsolete. Use ShareAsync(IEnumerable<OVRSpaceUser>). To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
users
A collection of Oculus users to share the anchor with.
onComplete
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.
(Obsolete) Erases the OVRSpatialAnchor from persistent storage.
This method is asynchronous. Use onComplete to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor. Deprecated
This method is obsolete. Use EraseAsync(). To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
onComplete
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.
(Obsolete) Erases the OVRSpatialAnchor from specified storage.
This method is asynchronous. Use onComplete to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor. Deprecated
This method is obsolete. Use EraseAsync(EraseOptions). To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
eraseOptions
Options how the anchor should be erased.
onComplete
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.
(Obsolete) Erases the OVRSpatialAnchor from specified storage.
This method is asynchronous; use the returned OVRTask<TResult> to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor. Deprecated
This method is obsolete. Use EraseAnchorAsync instead.
Returns
An OVRTask<TResult> with a boolean type parameter indicating the success of the erase operation.
(Obsolete) Erases the OVRSpatialAnchor from specified storage.
This method is asynchronous; use the returned OVRTask<TResult> to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor. Deprecated
This method is obsolete. Use EraseAnchorAsync instead.
Parameters
eraseOptions
Options for how the anchor should be erased.
Returns
An OVRTask<TResult> with a boolean type parameter indicating the success of the erase operation.
(Obsolete) Saves the OVRSpatialAnchor with specified SaveOptions.
This method is asynchronous; use the returned OVRTask<TResult> 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. Deprecated
This method is obsolete. Use SaveAnchorAsync instead.
Returns
An OVRTask<TResult> with a boolean type parameter indicating the success of the save operation.
(Obsolete) Saves the OVRSpatialAnchor with specified SaveOptions.
This method is asynchronous; use the returned OVRTask<TResult> 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. Deprecated
This method is obsolete. Use SaveAnchorAsync instead.
Parameters
saveOptions
Options for how the anchor will be saved.
Returns
An OVRTask<TResult> with a boolean type parameter indicating the success of the save operation.

Static Member Functions

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<TResult> to monitor completion.This operation fully succeeds or fails, which means, either all anchors are successfully shared or the operation fails.
Parameters
anchors
The collection of anchors to share.
users
An array of Oculus users to share these anchors with.
Returns
A task that can be used to track the completion of the sharing operation.
Exceptions
ArgumentNullException
Thrown if anchors is null.
ArgumentNullException
Thrown if users is null.
Saves a collection of anchors.
This method is asynchronous; use the returned OVRTask<TResult> 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.
Parameters
anchors
The anchors to save (up to 32).
Returns
An awaitable OVRTask<TResult> representing the asynchronous save operation.
Exceptions
ArgumentNullException
Thrown if anchors is null.
Exceptions
ArgumentException
Thrown if anchors contains more than 32 anchors.
Erase a collection of anchors from persistent storage.
This operation is asynchronous. Use the returned OVRTask<TResult> to track the result of the asynchronous operation.The total number of anchors (anchors and uuids ) may not exceed 32.
Parameters
anchors
(Optional) The anchors to erase
uuids
(Optional) The UUIDs to erase
Returns
An awaitable OVRTask<TResult> representing the asynchronous erase operation.
Exceptions
ArgumentException
Thrown if anchors and uuids are both null.
Exceptions
ArgumentException
Thrown if the combined number of anchors and uuids is greater than 32.
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<TResult> 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.
Parameters
uuids
The UUIDs of the anchors to load.
unboundAnchors
The buffer to store the resulting unbound anchors into.
onIncrementalResultsAvailable
An optional callback that is invoked whenever a new batch of unbound anchors has been loaded.
Returns
A new OVRTask<TResult> that completes when the loading operation completes.
Exceptions
ArgumentNullException
Thrown if uuids is null.
ArgumentNullException
Thrown if unboundAnchors is null.
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: To load other types of anchors, use LoadUnboundAnchorsAsync(IEnumerable<Guid>,List<UnboundAnchor>,Action<List<UnboundAnchor>,int>).
Parameters
uuids
The set of anchor UUIDs to load
unboundAnchors
A buffer to store the loaded anchors. This container is cleared before being populated.
Returns
Returns an awaitable task-like object that can be used to track completion of the load operation.
Exceptions
ArgumentNullException
Thrown if uuids is null.
ArgumentNullException
Thrown if unboundAnchors is null.
Create an unbound spatial anchor from an
See Also
.
Only spatial anchors retrieved as
See Also
s should use this method. Using this function on system-managed scene anchors will succeed, but certain functions will not work.
Parameters
anchor
The
See Also
to create the unbound anchor for.
unboundAnchor
The created unboundAnchor.
Returns
True if anchor is localizable and is not already bound to an OVRSpatialAnchor, otherwise false.
(Obsolete) Performs a query for anchors with the specified options .
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.
Parameters
options
Options that affect the query.
onComplete
A delegate invoked when the query completes. The delegate accepts one argument:
If the operation fails, onComplete is invoked with null.Deprecated
This method is obsolete. Use LoadUnboundAnchorsAsync. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Returns
Returns true if the operation could be initiated; otherwise false.
Exceptions
ArgumentNullException
Thrown if onComplete is null.
InvalidOperationException
Thrown if LoadOptions.Uuids of options is null.
(Obsolete) Shares a collection of OVRSpatialAnchor to specified users.
Specified users will be able to download, track, and share specified anchors.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. Deprecated
This method is obsolete. Use ShareAsync(IEnumerable<OVRSpatialAnchor>,IEnumerable<OVRSpaceUser>) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
anchors
The collection of anchors to share.
users
An array of Oculus users to share these anchors with.
onComplete
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.
Exceptions
ArgumentNullException
Thrown if anchors is null.
ArgumentNullException
Thrown if users is null.
(Obsolete) Saves a collection of anchors to persistent storage.
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. Deprecated
This method is obsolete. Use SaveAsync(IEnumerable<OVRSpatialAnchor>, SaveOptions) instead. To continue using the onComplete callback, use OVRTask<T>.ContinueWith on the returned task.
Parameters
anchors
Collection of anchors
saveOptions
Save options, e.g., whether local or cloud.
onComplete
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.
Exceptions
ArgumentNullException
Thrown if anchors is null.
(Obsolete) Saves a collection of anchors to persistent storage.
This method is asynchronous. Use the returned OVRTask<TResult> 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. Deprecated
This method is obsolete. Use SaveAnchorsAsync instead.
Parameters
anchors
The collection of anchors to save.
saveOptions
Save options, e.g., whether local or cloud.
Returns
A task that represents the asynchronous save operation.
Exceptions
ArgumentNullException
Thrown if anchors is null.
(Obsolete) Performs a query for anchors with the specified options .
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<TResult> will contain an array of UnboundAnchors for which tracking may be requested. Deprecated
This method is obsolete. Use LoadUnboundAnchorsAsync(IEnumerable<Guid>,List<UnboundAnchor>,Action<List<UnboundAnchor>, int> instead.
Parameters
options
Options that affect the query.
Returns
An OVRTask<TResult> with a T:UnboundAnchor[] type parameter containing the loaded unbound anchors.
Exceptions
InvalidOperationException
Thrown if LoadOptions.Uuids of options is null.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon