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

OVRSpatialAnchor Class

Represents a spatial anchor.
OVRSpatialAnchor extends MonoBehaviour.

Overview

Properties

_anchor[Get]
Guid
Uuid[Get]
The UUID associated with the spatial anchor.
bool
Created[Get]
Checks whether the spatial anchor is created.
bool
Checks whether the spatial anchor is pending creation.
bool
Checks whether the spatial anchor is localized.
Space[Get]
The space associated with the spatial anchor.

Events

Action< OperationResult >
Event that is dispatched when the localization process finishes.

Public Member Functions

OVRTask< bool >
Saves the OVRSpatialAnchor with specified SaveOptions.
OVRTask< bool >
SaveAsync
( SaveOptions saveOptions )
Saves the OVRSpatialAnchor with specified SaveOptions.
Shares the anchor to an OVRSpaceUser.
Shares the anchor to an OVRSpaceUser.
Shares the anchor to an OVRSpaceUser.
Shares the anchor to an OVRSpaceUser.
ShareAsync
( IEnumerable< OVRSpaceUser > users )
Shares the anchor to an OVRSpaceUser.
OVRTask< bool >
Erases the OVRSpatialAnchor from specified storage.
OVRTask< bool >
EraseAsync
( EraseOptions eraseOptions )
Erases the OVRSpatialAnchor from specified storage.
void
InitializeFromExisting
( OVRSpace space,
Guid uuid )
Initializes this component from an existing space handle and uuid, e.g., the result of a call to OVRPlugin.QuerySpaces.
void
Save
( Action< OVRSpatialAnchor, bool > onComplete )
Saves the OVRSpatialAnchor to local persistent storage.
void
Save
( SaveOptions saveOptions,
Action< OVRSpatialAnchor, bool > onComplete )
Saves the OVRSpatialAnchor with specified SaveOptions.
void
Share
( OVRSpaceUser user,
Action< OperationResult > onComplete )
Shares the anchor to an OVRSpaceUser.
void
Share
( OVRSpaceUser user1,
OVRSpaceUser user2,
Action< OperationResult > onComplete )
Shares the anchor with two OVRSpaceUser.
void
Share
( OVRSpaceUser user1,
OVRSpaceUser user2,
OVRSpaceUser user3,
Action< OperationResult > onComplete )
Shares the anchor with three OVRSpaceUser.
void
Share
( OVRSpaceUser user1,
OVRSpaceUser user2,
OVRSpaceUser user3,
OVRSpaceUser user4,
Action< OperationResult > onComplete )
Shares the anchor with four OVRSpaceUser.
void
Share
( IEnumerable< OVRSpaceUser > users,
Action< OperationResult > onComplete )
Shares the anchor to a collection of OVRSpaceUser.
void
Erase
( Action< OVRSpatialAnchor, bool > onComplete )
Erases the OVRSpatialAnchor from persistent storage.
void
Erase
( EraseOptions eraseOptions,
Action< OVRSpatialAnchor, bool > onComplete )
Erases the OVRSpatialAnchor from specified storage.

Static Public Member Functions

SaveAsync
( IEnumerable< OVRSpatialAnchor > anchors,
SaveOptions saveOptions )
Saves a collection of anchors to persistent storage.
ShareAsync
( IEnumerable< OVRSpatialAnchor > anchors,
IEnumerable< OVRSpaceUser > users )
Shares a collection of anchors with a collection of users.
Performs a query for anchors with the specified options .
static bool
FromOVRAnchor
( OVRAnchor anchor,
out UnboundAnchor unboundAnchor )
Create an unbound spatial anchor from an
See Also:
.
static bool
LoadUnboundAnchors
( LoadOptions options,
Action< UnboundAnchor[]> onComplete )
Performs a query for anchors with the specified options .
static void
Share
( ICollection< OVRSpatialAnchor > anchors,
ICollection< OVRSpaceUser > users,
Action< ICollection< OVRSpatialAnchor >, OperationResult > onComplete )
Shares a collection of OVRSpatialAnchor to specified users.
static void
Save
( ICollection< OVRSpatialAnchor > anchors,
SaveOptions saveOptions,
Action< ICollection< OVRSpatialAnchor >, OperationResult > onComplete )
Saves a collection of anchors to persistent storage.

Details

Detailed Description

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.
To load previously saved anchors and bind them to an OVRSpatialAnchor, see LoadUnboundAnchorsAsync.

Member Enumerations

enum OVRSpatialAnchor.OperationResult
Enumerator
Success
Operation succeeded.
Failure
Operation failed.
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 OVRSpatialAnchor._anchor
No description available.
Guid OVRSpatialAnchor.Uuid
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.
bool OVRSpatialAnchor.Created
Checks whether the spatial anchor is created.
Creation is asynchronous and may take several frames. If creation fails, the component is destroyed.
bool OVRSpatialAnchor.PendingCreation
Checks whether the spatial anchor is pending creation.
bool OVRSpatialAnchor.Localized
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.
OVRSpace OVRSpatialAnchor.Space
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

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

Member Functions

OVRTask< bool > OVRSpatialAnchor.SaveAsync ( )
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.
Returns
An OVRTask<TResult> with a boolean type parameter indicating the success of the save operation.
OVRTask< bool > OVRSpatialAnchor.SaveAsync
( SaveOptions saveOptions )
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.
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.
OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync
( OVRSpaceUser 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.
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.
OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync
( OVRSpaceUser user1,
OVRSpaceUser 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.
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.
OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync
( OVRSpaceUser user1,
OVRSpaceUser user2,
OVRSpaceUser 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.
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.
OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync
( OVRSpaceUser user1,
OVRSpaceUser user2,
OVRSpaceUser user3,
OVRSpaceUser 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.
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.
OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync
( IEnumerable< OVRSpaceUser > 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.
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.
OVRTask< bool > OVRSpatialAnchor.EraseAsync ( )
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.
Returns
An OVRTask<TResult> with a boolean type parameter indicating the success of the erase operation.
OVRTask< bool > OVRSpatialAnchor.EraseAsync
( EraseOptions eraseOptions )
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.
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.
void OVRSpatialAnchor.InitializeFromExisting
( OVRSpace space,
Guid uuid )
Initializes this component from an existing space handle and uuid, e.g., the result of a call to OVRPlugin.QuerySpaces.
NOTE: 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.
void OVRSpatialAnchor.Save
( Action< OVRSpatialAnchor, bool > onComplete )
Saves the OVRSpatialAnchor to local persistent storage.
NOTE: This 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.
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.
void OVRSpatialAnchor.Save
( SaveOptions saveOptions,
Action< OVRSpatialAnchor, bool > onComplete )
Saves the OVRSpatialAnchor with specified SaveOptions.
NOTE: This 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.
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.
void OVRSpatialAnchor.Share
( OVRSpaceUser user,
Action< OperationResult > onComplete )
Shares the anchor to an OVRSpaceUser.
The specified user will be able to download, track, and share specified anchors.
NOTE: This 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.
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.
void OVRSpatialAnchor.Share
( OVRSpaceUser user1,
OVRSpaceUser user2,
Action< OperationResult > onComplete )
Shares the anchor with two OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
NOTE: This 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.
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.
void OVRSpatialAnchor.Share
( OVRSpaceUser user1,
OVRSpaceUser user2,
OVRSpaceUser user3,
Action< OperationResult > onComplete )
Shares the anchor with three OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
NOTE: This 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.
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.
void OVRSpatialAnchor.Share
( OVRSpaceUser user1,
OVRSpaceUser user2,
OVRSpaceUser user3,
OVRSpaceUser user4,
Action< OperationResult > onComplete )
Shares the anchor with four OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
NOTE: 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.
This method is asynchronous. Use onComplete 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.
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.
void OVRSpatialAnchor.Share
( IEnumerable< OVRSpaceUser > users,
Action< OperationResult > onComplete )
Shares the anchor to a collection of OVRSpaceUser.
Specified users will be able to download, track, and share specified anchors.
NOTE: This 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.
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.
void OVRSpatialAnchor.Erase
( Action< OVRSpatialAnchor, bool > onComplete )
Erases the OVRSpatialAnchor from persistent storage.
NOTE: This 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.
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.
void OVRSpatialAnchor.Erase
( EraseOptions eraseOptions,
Action< OVRSpatialAnchor, bool > onComplete )
Erases the OVRSpatialAnchor from specified storage.
NOTE: This 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.
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.

Static Member Functions

static OVRTask< OperationResult > OVRSpatialAnchor.SaveAsync
( IEnumerable< OVRSpatialAnchor > anchors,
SaveOptions saveOptions )
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.
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.
static OVRTask< OperationResult > OVRSpatialAnchor.ShareAsync
( IEnumerable< OVRSpatialAnchor > anchors,
IEnumerable< OVRSpaceUser > 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.
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.
static OVRTask< UnboundAnchor[]> OVRSpatialAnchor.LoadUnboundAnchorsAsync
( LoadOptions options )
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.
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.
static bool OVRSpatialAnchor.FromOVRAnchor
( OVRAnchor anchor,
out UnboundAnchor unboundAnchor )
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.
static bool OVRSpatialAnchor.LoadUnboundAnchors
( LoadOptions options,
Action< UnboundAnchor[]> onComplete )
Performs a query for anchors with the specified options .
NOTE: This 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.
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.
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.
static void OVRSpatialAnchor.Share
( ICollection< OVRSpatialAnchor > anchors,
ICollection< OVRSpaceUser > users,
Action< ICollection< OVRSpatialAnchor >, OperationResult > onComplete )
Shares a collection of OVRSpatialAnchor to specified users.
Specified users will be able to download, track, and share specified anchors.
NOTE: 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.
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.
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.
static void OVRSpatialAnchor.Save
( ICollection< OVRSpatialAnchor > anchors,
SaveOptions saveOptions,
Action< ICollection< OVRSpatialAnchor >, OperationResult > onComplete )
Saves a collection of anchors to persistent storage.
NOTE: This 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.
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.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon