コード例 #1
0
        /// <summary>
        /// starts feed process
        /// contextCall is meant to filter if feeder must be called again
        /// </summary>
        public void feed()
        {
            Debug.Log(GetType() + "::feed()", transform);

            string[] nms = solveNames();

            //Debug.Log(EngineObject.getStamp(this) + " now feeding "+nms.Length+" names", transform);
            //for (int i = 0; i < nms.Length; i++) { Debug.Log("  L " + nms[i]);}

            feeding = EngineLoader.loadScenes(nms, delegate()
            {
                //Debug.Log("feed destroy");
                GameObject.Destroy(this);
            });
        }
コード例 #2
0
        IEnumerator processStartup()
        {
            Coroutine co = null;

            Debug.Log(getStamp() + " process startup, frame : " + Time.frameCount);

            //leave a few frame for loading screen to be created and displayed
            //Scene are not flagged as loaded during frame 1
            yield return(null);

            yield return(null);

            yield return(null);

            //EngineLoader.loadScene("screen-loading");
            //ScreenLoading.create(false);
            ScreenLoading.showLoadingScreen();

            //Debug.Log(getStamp() + " waiting for loading screen");
            //attendre l'écran de loading
            //while (ScreenLoading.get() == null) yield return null;

            //Debug.Log(getStamp() + " loading screen should be visible, frame : " + Time.frameCount);

            string engineSceneName = EngineLoader.prefixResource + "engine";

            //Debug.Log(getStamp() + " triggering feeders ...");

            // then we load engine, to get the feeder script
            co = EngineLoader.loadScenes(new string[] { engineSceneName },
                                         delegate() { co = null; });

            Debug.Log(getStamp() + " waiting for engine scene ...");

            while (co != null)
            {
                yield return(null);
            }

            //NEEDED if not present
            //must be created after the (existing ?) engine scene is loaded (doublon)
            //EngineManager.create();

            //safe check for engine scene presence
            Scene engineScene = SceneManager.GetSceneByName(engineSceneName);

            Debug.Assert(engineScene.IsValid());

            while (!engineScene.isLoaded)
            {
                yield return(null);
            }
            yield return(null);

            Debug.Log(getStamp() + " triggering feeders ...");

            // les feeders qui sont déjà présents quand on lance le runtime (pas par un load)
            EngineLoaderFeederBase[] feeders = GameObject.FindObjectsOfType <EngineLoaderFeederBase>();
            Debug.Log(getStamp() + " " + feeders.Length + " feeders still running");
            for (int i = 0; i < feeders.Length; i++)
            {
                //feeders[i].feed(gameObject.scene);
                if (!feeders[i].isFeeding())
                {
                    feeders[i].feed();
                }
            }

            //tant qu'on a des loaders qui tournent ...
            while (EngineLoader.areAnyLoadersRunning())
            {
                yield return(null);
            }

            Debug.Log(getStamp() + " is done at frame " + Time.frameCount + ", removing gameobject");

            if (engineScene.rootCount <= 0)
            {
                SceneManager.UnloadSceneAsync(engineScene);
            }

            EngineBoot booter = GameObject.FindObjectOfType <EngineBoot>();

            if (booter == null)
            {
                Debug.LogWarning(getStamp() + " no booter found ?");
            }
            else
            {
                booter?.loadingCompleted();
            }

            yield return(null);

            //temp
            ScreenLoading.hideLoadingScreen();

            yield return(null);

            GameObject.Destroy(gameObject);
        }