示例#1
0
        void Update()
        {
            var delta = time.delta * time.Default.timeScale;


            if (Toolbox.changingScene)
            {
                return;
            }


            for (int i = 0; i < timesLen; i++)
            {
                times[i].Tick();
            }

            for (var i = 0; i < countTicks; i++)
            {
                ticks[i].Tick(delta);
            }


            ProcessorEntities.Tick(delta);

            for (var i = 0; i < countTicksProc; i++)
            {
                ticksProc[i].Tick(delta);
                ProcessorEntities.Tick(delta);
            }

            routines.Default.Tick(delta);
        }
示例#2
0
        void Update()
        {
            var delta = time.delta;


            routines.Global.Tick(time.deltaUnscaled);

            if (Toolbox.changingScene)
            {
                return;
            }

            for (var i = 0; i < timesLen; i++)
            {
                times[i].Tick();
            }

            ProcessorEntities.Execute();

            for (var i = 0; i < countTicks; i++)
            {
                ticks[i].Tick(delta);
            }

            for (var i = 0; i < countTicksProc; i++)
            {
                ticksProc[i].Tick(delta);
            }

            for (var i = 0; i < ProcessorCoroutines.coroutine_handlers.Count; i++)
            {
                ProcessorCoroutines.coroutine_handlers[i].Tick(delta);
            }
        }
示例#3
0
        void LateUpdate()
        {
            if (Toolbox.changingScene)
            {
                return;
            }
            var delta = time.delta;

            for (var i = 0; i < countTicksLate; i++)
            {
                ticksLate[i].TickLate(delta);
                ProcessorEntities.Tick(delta);
            }
        }
示例#4
0
        void FixedUpdate()
        {
            if (Toolbox.changingScene)
            {
                return;
            }
            var delta = time.deltaFixed;

            for (var i = 0; i < countTicksFixed; i++)
            {
                ticksFixed[i].TickFixed(delta);
                ProcessorEntities.Tick(delta);
            }
        }
示例#5
0
        IEnumerator _Load(string name)
        {
            void CalculateProgress(AsyncOperation curJob, int _totalStages, ref float _prevProgress, ref float _curProgress)
            {
                _curProgress += curJob.progress / _totalStages - _prevProgress;
                _prevProgress = curJob.progress / _totalStages;

                _curProgress = Mathf.Clamp(_curProgress, 0f, 1f);
                OnSceneLoading(_curProgress);
            }

            routines.Default.StopAll();
            OnSceneClose();
            ProcessorEntities.Clean();
            Toolbox.changingScene = true;
            Toolbox.Instance.ClearSessionData();

            //Plus two for unload assets and load target scene
            int   totalStagesNeed = 0;
            float curProgress = 0f, prevProgress = 0f;

            AsyncOperation job            = null;
            List <string>  scenesToUnload = new List <string>();

            //Add main scene
            scenesToUnload.Add(SceneManager.GetActiveScene().name);
            //Add additive scenes
            scenesToUnload.AddRange(sceneDependsOn);
            //Exclude scenes to keep
            scenesToUnload.RemoveAll((scene) => scenesToKeep.Contains(scene));

            totalStagesNeed = scenesToUnload.Count + 2;

            //Do all work
            for (int i = 0; i < totalStagesNeed; i++)
            {
                //Unload scenes
                if (i < scenesToUnload.Count)
                {
                    string key = scenesToUnload[i];

                    job = SceneManager.UnloadSceneAsync(scenes[key]);
                }
                //Cleaning
                else if (i < totalStagesNeed - 1)
                {
                    job = Resources.UnloadUnusedAssets();
                }
                //Load target scene
                else if (i < totalStagesNeed)
                {
                    scenes.Clear();
                    job = SceneManager.LoadSceneAsync(name, LoadSceneMode.Additive);
                }

                //Calculate progress
                while (!job.isDone)
                {
                    CalculateProgress(job, totalStagesNeed, ref prevProgress, ref curProgress);
                    yield return(0);
                }

                CalculateProgress(job, totalStagesNeed, ref prevProgress, ref curProgress);
                prevProgress = 0f;
            }

            SceneManager.SetActiveScene(SceneManager.GetSceneByName(name));
            job.allowSceneActivation = true;
            Toolbox.changingScene    = false;
        }
示例#6
0
        IEnumerator _Load(int id)
        {
            routines.Default.StopAll();
            ProcessorEntities.Clean();
            OnSceneClose();
            Toolbox.changingScene = true;
            Toolbox.Instance.ClearSessionData();

            if (scenes.Keys.Count == 1)
            {
                scenes.Clear();

                var jScene = SceneManager.LoadSceneAsync(id);
                while (!jScene.isDone)
                {
                    yield return(0);
                }
                SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(id));
                Toolbox.changingScene = false;
                yield break;
            }

            var s     = SceneManager.GetActiveScene();
            var sName = s.name;

            var job = SceneManager.UnloadSceneAsync(s);

            while (!job.isDone)
            {
                yield return(0);
            }


            scenes.Remove(sName);

            if (scenes.Keys.Count != 1)
            {
                foreach (var key in scenes.Keys)
                {
                    if (scenesToKeep.Contains(key))
                    {
                        continue;
                    }

                    job = SceneManager.UnloadSceneAsync(scenes[key]);

                    while (!job.isDone)
                    {
                        yield return(0);
                    }
                }

                job = Resources.UnloadUnusedAssets();
                while (!job.isDone)
                {
                    yield return(0);
                }
            }


            scenes.Clear();

            job = SceneManager.LoadSceneAsync(id, LoadSceneMode.Additive);
            while (!job.isDone)
            {
                yield return(0);
            }

            SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(id));
            job.allowSceneActivation = true;
            Toolbox.changingScene    = false;
        }