Example #1
0
        IEnumerator Init()
        {
            //MagicLeapLogger.Debug(kLogTag, "Checking for XRGeneralSettings.Instance");
            while (XRGeneralSettings.Instance == null)
            {
                //MagicLeapLogger.Debug(kLogTag, "Waiting for XRGeneralSettings.Instance to spawn");
                yield return(null);
            }
            //MagicLeapLogger.Debug(kLogTag, "Checking for XRGeneralSettings.Instance.Manager");
            while (XRGeneralSettings.Instance.Manager == null)
            {
                //MagicLeapLogger.Debug(kLogTag, "Waiting for XRGeneralSettings.Instance.Manager to spawn");
                yield return(null);
            }
            m_Loader = XRGeneralSettings.Instance.Manager.ActiveLoaderAs <MagicLeapLoader>();
            MLLog.Assert(m_Loader != null, kLogTag, "Cannot get reference to MagicLeapLoader!");
            if (m_Loader != null)
            {
                m_MeshSubsystem = m_Loader.meshSubsystem;
            }

            MLLog.Assert(m_MeshSubsystem != null, kLogTag, "Cannot get reference to Mesh Subsystem!");

            UpdateSettings();
            UpdateBounds();
            UpdateBatchSize();

            StartSubsystem();
        }
Example #2
0
        IEnumerator Init()
        {
            //MagicLeapLogger.Debug(kLogTag, "Checking for XRGeneralSettings.Instance");
            while (XRGeneralSettings.Instance == null)
            {
                //MagicLeapLogger.Debug(kLogTag, "Waiting for XRGeneralSettings.Instance to spawn");
                yield return(null);
            }
            //MagicLeapLogger.Debug(kLogTag, "Checking for XRGeneralSettings.Instance.Manager");
            while (XRGeneralSettings.Instance.Manager == null)
            {
                //MagicLeapLogger.Debug(kLogTag, "Waiting for XRGeneralSettings.Instance.Manager to spawn");
                yield return(null);
            }
            m_Loader = XRGeneralSettings.Instance.Manager.ActiveLoaderAs <MagicLeapLoader>();
            MLLog.Assert(m_Loader != null, kLogTag, "Cannot get reference to MagicLeapLoader!");
            if (m_Loader == null)
            {
                //MagicLeapLogger.Debug(kLogTag, "Waiting for MagicleapLegacyLoader to spawn");
                while (MagicLeapLegacyLoader.instance == null)
                {
                    yield return(null);
                }
                //MagicLeapLogger.Debug(kLogTag, "Waiting for MagicleapLegacyLoader to initialize");
                while (!MagicLeapLegacyLoader.instance.isInitialized)
                {
                    yield return(null);
                }
                //MagicLeapLogger.Debug(kLogTag, "Attempting to load mesh subsystem from MagicLeapLegacyLoader");
                m_MeshSubsystem = MagicLeapLegacyLoader.instance.meshSubsystem;
                if (m_MeshSubsystem == null)
                {
                    enabled = false;
                    yield break;
                }
            }
            else
            {
                m_MeshSubsystem = m_Loader.meshSubsystem;
            }

            MLLog.Assert(m_MeshSubsystem != null, kLogTag, "Cannot get reference to Mesh Subsystem!");

            UpdateSettings();
            UpdateBounds();
            UpdateBatchSize();
            SetLod();

            StartSubsystem();
        }
        internal static void Shutdown()
        {
            // TODO :: Need to enfore access on main thread only..
            lock (s_LockObject)
            {
                s_RefCount--;
                if (s_RefCount > 0)
                {
                    return;
                }
            }
            MLLog.Debug(kLogTag, "Stopping Privileges Service");
            Application.quitting -= Shutdown;
            var result = Native.Shutdown();

            MLLog.Assert(result == ResultCode.Ok, kLogTag, "Failed to shutdown privileges service");
        }
        internal static void Initialize()
        {
            // TODO :: Need to enfore access on main thread only..
            lock (s_LockObject)
            {
                s_RefCount++;
                if (s_RefCount != 1)
                {
                    return;
                }
            }
            MLLog.Debug(kLogTag, "Starting Privileges Service");
            var result = Native.Startup();

            MLLog.Assert(result == ResultCode.Ok, kLogTag, "Failed to initialize privileges service");
            // on app shutdown, we're tearing the world down anyways, so futzing with the ref count is okay.
            Application.quitting += () => { Shutdown(); };
        }