private IEnumerator loadScene(string sceneName, LuaTable newStage)
        {
            LuaTable lastStage = curStage;

            curStage = newStage;


            CallFunction(lastStage, "onExit");

            stageLoader = new LoadStageAsync();
            CallFunction(newStage, "onEnter", stageLoader);

            while (stageLoader.MoveNext())
            {
                yield return(null);
            }

            SceneManager.LoadScene(sceneName);

            while (SceneManager.GetActiveScene().name != sceneName)
            {
                yield return(null);
            }

            //wait a frame
            yield return(null);

            this.OnCompleted();

            CallFunction(newStage, "onShow");
        }
        /// <summary>
        /// 异步加载场景
        /// </summary>
        /// <param name="newStage">场景Lua状态</param>
        /// <param name="activeImmediate">场景加载完成后是否立即切换</param>
        public void LoadSceneChunk(LuaTable newStage, bool activeImmediate)
        {
            LuaTable lastStage = curStage;

            curStage = newStage;

            //下个场景名
            string sceneName = newStage.GetStringField("stageName");

            nextSceneName = sceneName;

            stageLoader = new LoadStageAsync();

            CallFunction(lastStage, "onExit");

            SceneManager.LoadScene(sceneName + "_Base");
        }
        /// <summary>
        /// 异步加载场景
        /// </summary>
        /// <param name="newStage">场景Lua状态</param>
        /// <param name="activeImmediate">场景加载完成后是否立即切换</param>
        public void LoadSceneViaPreloading(LuaTable newStage, bool activeImmediate)
        {
            LuaTable lastStage = curStage;

            curStage = newStage;

            //下个场景名
            string sceneName = newStage.GetStringField("stageName");

            nextSceneName = sceneName;

            //过滤场景名
            string transitScene = newStage.GetStringField("transitScene");

            stageLoader = new LoadStageAsync(sceneName, activeImmediate);

            CallFunction(lastStage, "onExit");

            SceneManager.LoadScene(transitScene);
        }
Beispiel #4
0
        /// <summary>
        /// 预加载场景中的资源
        /// </summary>
        /// <param name="triggerGroup"></param>
        public void PreLoadCutscene(GameObject triggerGroup, LoadStageAsync stageLoader)
        {
            if (triggerGroup == null)
            {
                return;
            }

            GameObject.DontDestroyOnLoad(triggerGroup);
            caches.Add(triggerGroup);

            Transform     triggerGroupTrans = triggerGroup.transform;
            List <string> cutsenes          = new List <string>();

            for (int i = 0, count = triggerGroupTrans.childCount; i < count; i++)
            {
                Transform childTrans = triggerGroupTrans.GetChild(i);
                if (!childTrans.gameObject.activeSelf)
                {
                    continue;
                }

                string cutsceneId = childTrans.name.Substring(7);   //name = Trigger + id
                if (!triggered.Contains(Convert.ToInt32(cutsceneId)))
                {
                    cutsenes.Add(cutsceneId);
                }
            }

            cutsenes.Sort();

            for (int i = 0; i < cutsenes.Count; i++)
            {
                string         resPath        = string.Concat("Prefab/Cutscene/Cutscene", cutsenes[i]);
                ALoadOperation loadAssetAsync = ResourceManager.LoadBundleAsync(resPath);
                loadAssetAsync.OnFinish = instanceCutscene;
                stageLoader.AddLoader(loadAssetAsync, 5);
            }
        }
Beispiel #5
0
 protected virtual void Awake()
 {
     ssm          = AppFacade.Instance.GetManager <SceneStageManager>();
     stagerLoader = ssm.stageLoader;
 }