mark sameh
mark sameh

Reputation: 1

can't save oculus spatial anchors (on cloud or locally)

When using the editor on my oculus quest 3 I can save spatial anchors locally and on cloud, but when I make Apk build and run it on the oculus I always getting fail in result

using method (OVRSpatialAnchor.Save()) or (OVRSpatialAnchor.SaveAsync()) and it Give me OVRSpatialAnchors.OperationResult => Failure when using OVRSpatialAnchor.SaveAsync(IEnumerable<OVRSpatialAnchor> anchors, SaveOptions saveOptions) I am using unity editor 2023 and (Meta XR ALl in one SDK v62) and here my SpatialAnchorManager code:

    private void CreateAnchor()
    {
        var createdAnchor = Instantiate(anchor, OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch), OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch));
        var spatialAnchor = createdAnchor.AddComponent<OVRSpatialAnchor>();
        StartCoroutine(InitSpatialAnchor(spatialAnchor));
    }

    private IEnumerator InitSpatialAnchor(OVRSpatialAnchor anchor)
    {
        yield return WaitForInit(anchor);
        yield return SaveAsync(anchor);
        // OnAnchorCreateCompleted?.Invoke(anchor);
    }

    protected IEnumerator WaitForInit(OVRSpatialAnchor anchor)
    {
        while (anchor && (!anchor.Created || !anchor.Localized))
            yield return null;

        if (anchor == null)
        {
            Debug.LogWarning($" Failed to create the spatial anchor.");
        }
        else
        {
            var a = anchor.GetComponent<Anchor>();
            a.Uuid.text = $"Uuid: {anchor.Uuid}";

        }


    }

    protected IEnumerator SaveAsync(OVRSpatialAnchor anchor)
    {
        var task = anchor.SaveAsync();
        while (!task.IsCompleted)
            yield return null;

        try
        {
            if (!task.GetResult())
            {
                var ex = task.GetType();
                debugText.text = $" Failed to save the spatial anchor.";
                Debug.LogWarning($" Failed to save the spatial anchor.");
            }
            else
            {
                var a = anchor.GetComponent<Anchor>();
                a.Status.text = $"Saved!!";
                PlayerPrefs.SetString("lastCreatedAnchor", anchor.Uuid.ToString());
            }
        }
        catch (Exception ex)
        {
            debugText.text = $"Exception After Saving: {ex.InnerException?.Message ?? ex.Message}";
        }
    }

Upvotes: 0

Views: 533

Answers (1)

mark sameh
mark sameh

Reputation: 1

It worked fine after switching from work account to personal account on the oculus.

it seems work account was having issues with the spatial anchors.

Upvotes: 0

Related Questions