Example #1
0
        public override bool StartService(Settings settings)
        {
            if (m_Session == null)
            {
                var sessionConfig = ScriptableObject.CreateInstance <SessionConfig>();

                // We're going to manage the camera separately, but this needs to be true
                // so the ARCore native API knows we're going to use the camera.
                sessionConfig.m_enableARBackground = true;
                sessionConfig.m_enablePlaneFinding = settings.enablePlaneDetection;
                sessionConfig.m_enablePointcloud   = settings.enablePointCloud;

                var gameObject = new GameObject("Session Manager");

                // Deactivate the GameObject before adding the SessionComponent
                // or else the Awake method will be called before we have set
                // the session config.
                gameObject.SetActive(false);
                m_Session = gameObject.AddComponent <SessionComponent>();
                m_Session.m_connectOnAwake  = false;
                m_Session.m_arSessionConfig = sessionConfig;

                // We are going to manage the camera separately, so
                // intentionally leave null.
                m_Session.m_firstPersonCamera = null;
                gameObject.SetActive(true);
            }

            m_Session.Connect();
            return(SessionManager.ConnectionState == SessionConnectionState.Connected);
        }