“ ARCoreSession需要SessionConfig”在我尝试创建新的ARCoreSession时发生

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

我正在应用程序中创建和销毁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”

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

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

c# android unity3d augmented-reality arcore
1个回答
0
投票

我有相同的错误。我不确定是否缺少依赖项。

使用ArFoundation 3.01和Unity 2019.2.16f1。

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