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.

Properties

Created : bool
[Get]
Checks whether the spatial anchor is created.
Creation is asynchronous and may take several frames. If creation fails, the component is destroyed.
Signature
bool OVRSpatialAnchor.Created
Localized : bool
[Get]
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.
Signature
bool OVRSpatialAnchor.Localized
PendingCreation : bool
[Get]
Checks whether the spatial anchor is pending creation.
Signature
bool OVRSpatialAnchor.PendingCreation
Space : OVRSpace
[Get]
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.
Signature
OVRSpace OVRSpatialAnchor.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 OVRSpatialAnchor.Uuid

Events

OnLocalize : Action< OperationResult >
Event that is dispatched when the localization process finishes.
Signature
Action<OperationResult> OVRSpatialAnchor.OnLocalize

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 OVRSpatialAnchor.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 OVRSpatialAnchor.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<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.
Signature
OVRTask< OVRResult< OVRAnchor.EraseResult > > OVRSpatialAnchor.EraseAnchorAsync()
Returns
OVRTask< OVRResult< OVRAnchor.EraseResult > >  An awaitable OVRTask<TResult> 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<TResult> to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor.
Signature
OVRTask< bool > OVRSpatialAnchor.EraseAsync()
Returns
OVRTask< bool >  An OVRTask<TResult> with a boolean type parameter 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<TResult> to be notified of completion. Erasing an OVRSpatialAnchor does not destroy the anchor.
Signature
OVRTask< bool > OVRSpatialAnchor.EraseAsync(EraseOptions eraseOptions)
Parameters
eraseOptions: EraseOptions  Options for how the anchor should be erased.
Returns
OVRTask< bool >  An OVRTask<TResult> with a boolean type parameter indicating the success of the erase operation.
InitializeFromExisting ( space , uuid )
(Obsolete) Initializes this component from an existing space handle and uuid, e.g., 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 OVRSpatialAnchor.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 OVRSpatialAnchor.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 OVRSpatialAnchor.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<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.
Signature
OVRTask< OVRResult< OVRAnchor.SaveResult > > OVRSpatialAnchor.SaveAnchorAsync()
Returns
OVRTask< OVRResult< OVRAnchor.SaveResult > >  An awaitable OVRTask<TResult> 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<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.
Signature
OVRTask< bool > OVRSpatialAnchor.SaveAsync()
Returns
OVRTask< bool >  An OVRTask<TResult> with a boolean type parameter 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<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.
Signature
OVRTask< bool > OVRSpatialAnchor.SaveAsync(SaveOptions saveOptions)
Parameters
saveOptions: SaveOptions  Options for how the anchor will be saved.
Returns
OVRTask< bool >  An OVRTask<TResult> with a boolean type parameter 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 OVRSpatialAnchor.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 OVRSpatialAnchor.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 OVRSpatialAnchor.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 OVRSpatialAnchor.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 OVRSpatialAnchor.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<TResult> to be notified of completion.
Signature
OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync(OVRSpaceUser user)
Parameters
user: OVRSpaceUser  An Oculus user to share the anchor with.
Returns
OVRTask< OperationResult >  An OVRTask<TResult> with a OperationResult type parameter 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<TResult> to be notified of completion.
Signature
OVRTask< OperationResult > OVRSpatialAnchor.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 >  An OVRTask<TResult> with a OperationResult type parameter 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<TResult> to be notified of completion.
Signature
OVRTask< OperationResult > OVRSpatialAnchor.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 >  An OVRTask<TResult> with a OperationResult type parameter 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<TResult> to be notified of completion.
Signature
OVRTask< OperationResult > OVRSpatialAnchor.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 >  An OVRTask<TResult> with a OperationResult type parameter 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<TResult> to be notified of completion.
Signature
OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync(IEnumerable< OVRSpaceUser > users)
Parameters
users: IEnumerable< OVRSpaceUser >  A collection of Oculus users to share the anchor with.
Returns
OVRTask< OperationResult >  An OVRTask<TResult> with a OperationResult type parameter indicating the success of the share operation.

Static Methods

EraseAnchorsAsync ( anchors , uuids )
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.
Signature
static OVRTask< OVRResult< OVRAnchor.EraseResult > > OVRSpatialAnchor.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 > >  An awaitable OVRTask<TResult> representing the asynchronous erase operation.
Throws
ArgumentException  Thrown if anchors and uuids are both null. ArgumentException  Thrown if the combined number of anchors and uuids is greater than 32.
FromOVRAnchor ( anchor , unboundAnchor )
Create an unbound spatial anchor from an
Only spatial anchors retrieved as
Signature
static bool OVRSpatialAnchor.FromOVRAnchor(OVRAnchor anchor, out UnboundAnchor unboundAnchor)
Parameters
anchor: OVRAnchor  The
unboundAnchor: out UnboundAnchor  The created unboundAnchor.
Returns
bool  True if anchor is localizable and is not already bound to an OVRSpatialAnchor, otherwise false.
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 OVRSpatialAnchor.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<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.
Signature
static OVRTask< OVRResult< List< UnboundAnchor >, OVRAnchor.FetchResult > > OVRSpatialAnchor.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<TResult> 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<TResult> will contain an array of UnboundAnchors for which tracking may be requested.
Signature
static OVRTask< UnboundAnchor[]> OVRSpatialAnchor.LoadUnboundAnchorsAsync(LoadOptions options)
Parameters
options: LoadOptions  Options that affect the query.
Returns
OVRTask< UnboundAnchor[]>  An OVRTask<TResult> 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 "Shared Spatial Anchor Support" (OVRManager > Quest Features > General > Shared Spatial Anchor Support)
Signature
static OVRTask< OVRResult< List< UnboundAnchor >, OperationResult > > OVRSpatialAnchor.LoadUnboundSharedAnchorsAsync(IEnumerable< Guid > uuids, List< UnboundAnchor > unboundAnchors)
Parameters
uuids: IEnumerable< Guid >  The set of anchor UUIDs to load
unboundAnchors: List< UnboundAnchor >  A buffer to store the loaded anchors. This container is cleared before being populated.
Returns
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 uuids is null. ArgumentNullException  Thrown if 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 OVRSpatialAnchor.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<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.
Signature
static OVRTask< OVRResult< OVRAnchor.SaveResult > > OVRSpatialAnchor.SaveAnchorsAsync(IEnumerable< OVRSpatialAnchor > anchors)
Parameters
anchors: IEnumerable< OVRSpatialAnchor >  The anchors to save (up to 32).
Returns
OVRTask< OVRResult< OVRAnchor.SaveResult > >  An awaitable OVRTask<TResult> representing the asynchronous save operation.
Throws
ArgumentNullException  Thrown if anchors is null. ArgumentException  Thrown if anchors contains more than 32 anchors.
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<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.
Signature
static OVRTask< OperationResult > OVRSpatialAnchor.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 >  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 OVRSpatialAnchor.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<TResult> 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 > OVRSpatialAnchor.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 >  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.

Inner Structs

EraseOptions Struct

(Obsolete) Represents options for erasing OVRSpatialAnchor.
DeprecatedThis method is obsolete. You no longer need to provide a storage location when erasing anchors.

Fields

Location from where OVRSpatialAnchor will be erased.
Signature
OVRSpace.StorageLocation OVRSpatialAnchor.EraseOptions.Storage

LoadOptions Struct

(Obsolete) Options for loading unbound spatial anchors used by OVRSpatialAnchor.LoadUnboundAnchorsAsync(LoadOptions).
NOTE: This 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 OVRSpatialAnchor.LoadOptions.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 OVRSpatialAnchor.LoadOptions.MaxAnchorCount
StorageLocation : OVRSpace.StorageLocation
[Get][Set]
The storage location from which to query spatial anchors.
Signature
OVRSpace.StorageLocation OVRSpatialAnchor.LoadOptions.StorageLocation
Timeout : double
[Get][Set]
The timeout, in seconds, for the query operation.
A value of zero indicates no timeout.
Signature
double OVRSpatialAnchor.LoadOptions.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> OVRSpatialAnchor.LoadOptions.Uuids

SaveOptions Struct

(Obsolete) Represents options for saving OVRSpatialAnchor.

Fields

Location where OVRSpatialAnchor will be saved.
Signature
OVRSpace.StorageLocation OVRSpatialAnchor.SaveOptions.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 OVRSpatialAnchor.UnboundAnchor.Localized
Localizing : bool
[Get]
Whether the anchor is in the process of being localized.
Signature
bool OVRSpatialAnchor.UnboundAnchor.Localizing
Pose : Pose
[Get]
The world space pose of the spatial anchor.
Signature
Pose OVRSpatialAnchor.UnboundAnchor.Pose
Uuid : Guid
[Get]
The universally unique identifier associated with this anchor.
Signature
Guid OVRSpatialAnchor.UnboundAnchor.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 OVRSpatialAnchor.UnboundAnchor.BindTo(OVRSpatialAnchor spatialAnchor)
Parameters
spatialAnchor: OVRSpatialAnchor  The component to which this unbound anchor should be bound.
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 OVRSpatialAnchor.UnboundAnchor.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 > OVRSpatialAnchor.UnboundAnchor.LocalizeAsync(double timeout=0)
Parameters
timeout: double  The timeout, in seconds, to attempt localization, or zero to indicate no timeout.
Returns
OVRTask< bool >  An OVRTask<TResult> with a boolean type parameter indicating the success of the localization.
Throws
InvalidOperationException  Thrown if the anchor does not support localization, e.g., because it is invalid.

Inner Enum

OperationResult Enum

Possible results of operations related to anchor sharing.

Enumeration Constants

MemberValueDescription
Success
OVRPlugin.Result.Success
Operation succeeded.
Failure
OVRPlugin.Result.Failure
Operation failed.
Failure_DataIsInvalid
OVRPlugin.Result.Failure_DataIsInvalid
Invalid data.
Failure_SpaceCloudStorageDisabled
OVRPlugin.Result.Failure_SpaceCloudStorageDisabled
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.