无法保存 Oculus 空间锚点(在云端或本地)

问题描述 投票:0回答:1

在 oculus quest 3 上使用编辑器时,我可以在本地和云端保存空间锚点,但是当我在 oculus 上构建并运行 Apk 时,结果总是失败

使用方法(

OVRSpatialAnchor.Save()
)或(
OVRSpatialAnchor.SaveAsync()
) 它给我 OVRSpatialAnchors.OperationResult => 使用时失败
OVRSpatialAnchor.SaveAsync(IEnumerable<OVRSpatialAnchor> anchors, SaveOptions saveOptions)
我正在使用 unity editor 2023 和(Meta XR ALl in one SDK v62) 这是我的 SpatialAnchorManager 代码:

    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}";
        }
    }

unity-game-engine augmented-reality virtual-reality oculus azure-spatial-anchors
1个回答
0
投票

在 Oculus 上从工作帐户切换到个人帐户后,一切正常。

似乎work帐户的空间锚点存在问题。

© www.soinside.com 2019 - 2024. All rights reserved.