当我尝试创建新的ARCoreSession

时间:2019-10-25 14:09:00

标签: c# android unity3d augmented-reality arcore

我正在应用程序中创建和销毁ARCoreSession,以“忘记/销毁”旧的可跟踪对象(检测到的平面和特征点)。我正在使用Unity 2019.2.8f1和Unity ARCore SDK软件包1.11。

要创建和销毁会话,我使用以下代码。

    public void DestroyActualSession()
    {
        //if session exists destroy
        if (available)
        {
            //save SessionConfig and CameraConfigFilter
            mySession = myARCoreDevice.GetComponent<ARCoreSession>();
            myConfig = mySession.SessionConfig;
            myCameraConfigFilter = mySession.CameraConfigFilter;

            //destroy SessionComponent
            DestroyImmediate(mySession);
            available = false;
        }
    }

    public void CreateNewSession()
    {
        //if session doesn't exist you can create one
        if (!available)
        {
            //add ARCoreSession component to ARCoreDevice
            //error messages belongs to this line
            mySession = myARCoreDevice.AddComponent<ARCoreSession>();

            //set configuration
            mySession.SessionConfig = myConfig;
            mySession.CameraConfigFilter = myCameraConfigFilter;
            available = true;
        }
        //enable session
        mySession.enabled = true;
    }

工作正常。但是创建会话时,我无法摆脱以下错误:

-“ ARCoreSession需要SessionConfig”

-“ ARCoreSession需要CameraConfigFilter。要获取所有可用的配置,请将CameraConfigFilter设置为选择了所有选项的过滤器。”

似乎ARCoreSession类正在检查OnValidate()方法中的SessionConfig和CameraConfigFilter。但是在将ARCoreSession组件添加到我的ARCore设备之前,我没有找到一种设置配置的方法。

0 个答案:

没有答案