text
stringlengths 0
1.11k
|
|---|
The device setting ‘Share Point Cloud Data’ must be enabled for Shared Spatial Anchors to function. Users can find it under Settings > Privacy > Device Permissions > Share Point Cloud Data.
|
Your app can detect when this setting is disabled and inform users to turn it on. Your app will receive the error code OVRSpatialAnchor.OperationResult.Failure_SpaceCloudStorageDisabled on functions OVRSpatialAnchor.Save() or OVRSpatialAnchor.Share() when that setting is disabled. The error code can be read from the OperationResult. Upon receiving this error, you should inform users that enabling Share Point Cloud Data is required in order to use the colocated functionality and let them know where to find the setting. See samples below.
|
Handling error on Save
|
var anchors = Array.Empty<OVRSpatialAnchor>();
|
OVRSpatialAnchor.Save(anchors,
|
new OVRSpatialAnchor.SaveOptions
|
{
|
Storage = OVRSpace.StorageLocation.Cloud
|
},
|
onComplete: (_, result) =>
|
{
|
if (result == OVRSpatialAnchor.OperationResult.Failure_SpaceCloudStorageDisabled)
|
{
|
// inform user to turn on Share Point Cloud Data
|
// Settings > Privacy > Device Permissions > Turn on “Share Point Cloud Data”
|
}
|
});
|
Handling error on Share
|
if (await spatialAnchor.ShareAsync(users) ==
|
OVRSpatialAnchor.OperationResult.Failure_SpaceCloudStorageDisabled)
|
{
|
// inform user to turn on Share Point Cloud Data
|
// Settings > Privacy > Device Permissions > Turn on “Share Point Cloud Data”
|
}
|
OVRSpatialAnchor.Share() Details
|
The signature of OVRSpatialAnchor.Share() is as follows:
|
public static void Share(
|
ICollection<OVRSpatialAnchor> anchors,
|
ICollection<OVRSpaceUser> users,
|
Action<ICollection<OVRSpatialAnchor>, OperationResult> onComplete = null)
|
Parameters:
|
ICollection<OVRSpatialAnchor> anchors The collection of anchors you are sharing.
|
ICollection<OVRSpaceUser> users The collection of users with whom you are sharing.
|
Action onComplete Called when the operation completes. It takes two arguments:
|
ICollection<OVRSpatialAnchor> The collection of anchors that were shared.
|
OperationResult An error code indicating whether the share operation succeeded or not.
|
Spatial anchors in the anchors collection must already be saved to cloud storage. The users parameter specifies an array of OVRSpaceUser objects for the users with whom you want to share anchors. When the call to OVRSpatialAnchor.Share() succeeds, the SSAs are available to the users.
|
The sharing operation is asynchronous. You may supply an optional delegate to notify when the sharing operation completes. For example:
|
OVRSpatialAnchor.Share(anchorCollection, users, (anchors, result) =>
|
{
|
ShowShareIcon = result == OperationResult.Success;
|
});
|
OVRSpaceUser Object
|
You must specify the set of users with whom you wish to share anchors. To do this, create an OVRSpaceUser from each user’s Meta Quest ID (a ulong identifier).
|
var users = new OVRSpaceUser[]
|
{
|
new OVRSpaceUser(userId1),
|
new OVRSpaceUser(userId2),
|
};
|
OVRSpatialAnchor.Share(anchors, users, (anchors, result) => {
|
Debug.Log(result == OperationResult.Success ? $"Shared with {users.Length} users!" : "Sharing failed");
|
});
|
Refer to the Users, Friends, and Relationships section to see how to retrieve information about the current user and their friends.
|
Example
|
This excerpt from SharedAnchors.cs in the Unity-SharedSpatialAnchors showcase app demonstrates sharing spatial anchors to a user collection:
|
private void SaveToCloudThenShare()
|
{
|
OVRSpatialAnchor.SaveOptions saveOptions;
|
saveOptions.Storage = OVRSpace.StorageLocation.Cloud;
|
_spatialAnchor.Save(saveOptions, (spatialAnchor, isSuccessful) =>
|
{
|
if (isSuccessful)
|
{
|
SampleController.Instance.Log("Successfully saved anchor(s) to the cloud");
|
var userIds = PhotonAnchorManager.GetUserList().Select(userId => userId.ToString()).ToArray();
|
ICollection<OVRSpaceUser> spaceUserList = new List<OVRSpaceUser>();
|
foreach (string strUsername in userIds)
|
{
|
spaceUserList.Add(new OVRSpaceUser(ulong.Parse(strUsername)));
|
}
|
OVRSpatialAnchor.Share(new List<OVRSpatialAnchor> { spatialAnchor }, spaceUserList, OnShareComplete);
|
SampleController.Instance.AddSharedAnchorToLocalPlayer(this);
|
}
|
else
|
{
|
SampleController.Instance.Log("Saving anchor(s) failed. Retrying...");
|
SaveToCloudThenShare();
|
}
|
});
|
}
|
Find SharedAnchors.cs in the Unity-SharedSpatialAnchors showcase app at ./Assets/SharedSpatialAnchors/Scripts
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.