"SessionConfig is required by ARCoreSession" occurs when I try to create a new ARCoreSession

Viewed 1204

I'm creating and destroying the ARCoreSession in my application to "forget/destroy" the old trackables (detected planes and feature points). I'm using Unity 2019.2.8f1 and Unity ARCore SDK package 1.11.

To create and destroy the session I use the following code.

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

It works fine. But I am not able to get rid of the following errors when creating a session:

-"SessionConfig is required by ARCoreSession"

-"CameraConfigFilter is required by ARCoreSession. To get all available configurations, set CameraConfigFilter to a filter with all options selected."

It seems that the ARCoreSession Class is checking SessionConfig and CameraConfigFilter in the OnValidate()-method. But I didnt find a way to set the configuration before adding the ARCoreSession component to my ARCore Device.

0 Answers
Related