Exemplo n.º 1
0
        /// <summary>
        /// Iterate over the configured list of loaders and attempt to initialize each one. The first one
        /// that succeeds is set as the active loader and initialization immediately terminates.
        ///
        /// When complete, <see cref="isInitializationComplete"/> will be set to true. This will mark that it is safe to
        /// call other parts of the API, but does not guarantee that init successfully created a loader. To check that init successfully created a loader,
        /// you need to check that ActiveLoader is not null.
        ///
        /// **Note:** There can only be one active loader. Any attempt to initialize a new active loader with one
        /// already set will cause a warning to be logged and this function wil immeditely exit.
        ///
        /// Iteration is done asynchronously. You must call this method within the context of a Coroutine.
        /// </summary>
        ///
        /// <returns>Enumerator marking the next spot to continue execution at.</returns>
        public IEnumerator InitializeLoader()
        {
            if (activeLoader != null)
            {
                Debug.LogWarning(
                    "Adaptive Performance Management has already initialized an active loader in this scene." +
                    "Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.");
                yield break;
            }

            foreach (var loader in loaders)
            {
                if (loader != null)
                {
                    if (loader.Initialize())
                    {
                        activeLoader             = loader;
                        m_InitializationComplete = true;
                        yield break;
                    }
                }

                yield return(null);
            }

            activeLoader = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// If there is an active loader, this function will deinitialize it and remove the active loader instance from
        /// management. Unity will automatically call <see cref="StopSubsystems"/> before deinitialization to make sure
        /// that things are cleaned up appropriately.
        ///
        /// You must wait for <see cref="isInitializationComplete"/> to be set to true before calling this API.
        ///
        /// On return, <see cref="isInitializationComplete"/> will be set to false.
        /// </summary>
        public void DeinitializeLoader()
        {
            if (!m_InitializationComplete)
            {
                Debug.LogWarning(
                    "Call to DeinitializeLoader without an initialized manager." +
                    "Please make sure to wait for initialization to complete before calling this API.");
                return;
            }

            StopSubsystems();
            if (activeLoader != null)
            {
                activeLoader.Deinitialize();
                activeLoader = null;
            }

            m_InitializationComplete = false;
        }