Ejemplo n.º 1
0
        /// <summary>
        /// 切换场景
        /// </summary>
        /// <param name="type">指定的场景类型</param>
        /// <param name="curtain">指定的帷幕</param>
        /// <param name="args">初始化参数</param>
        public void SwitchScene(Type type, ISceneCurtain curtain, params object[] args)
        {
            if (m_RunningCoroutine != null)
            {
                throw new Exception("The last operation is still in progress !");
            }
            BaseScene nextScene = null;

            foreach (var scene in m_Scenes)
            {
                if (scene.GetType() == type)
                {
                    nextScene = scene;
                    break;
                }
            }
            if (nextScene == null)
            {
                nextScene = (BaseScene)Activator.CreateInstance(type);
            }
            m_IsDestroyingScene = true;
            m_RunningCoroutine  = new Coroutine(SwitchScene(CurrentScene, nextScene, curtain == null ? m_DefaultCurtain : curtain, args));
        }
Ejemplo n.º 2
0
        IEnumerator SwitchScene(BaseScene origScene, BaseScene nextScene, ISceneCurtain curtain, params object[] args)
        {
            if (origScene == nextScene)
            {
                m_IsDestroyingScene = false;
                yield break;
            }
            //落幕
            if (curtain != null)
            {
                yield return(curtain.Falls());
            }
            //关闭现有界面
            UIManager uiManager = GameFramework.GetModule <UIManager>();

            if (uiManager != null)
            {
                uiManager.CloseAll();
            }
            //卸载旧场景
            if (origScene != null)
            {
                yield return(InvokeExit(origScene));
            }
            //加载新场景
            yield return(ResourceManager.Instance.LoadSceneAsync(GetURL(nextScene)));

            m_IsDestroyingScene = false;
            yield return(InvokeEnter(nextScene, args));

            CurrentScene = nextScene;
            //揭幕
            if (curtain != null)
            {
                yield return(curtain.Raise());
            }
        }
Ejemplo n.º 3
0
 protected IEnumerator InvokeExit(BaseScene scene)
 {
     scene.isActive = false;
     yield return(scene.OnExit());
 }
Ejemplo n.º 4
0
 protected void InvokeLateUpdate(BaseScene scene, float elapseSeconds, float realElapseSeconds)
 {
     scene.OnLateUpdate(elapseSeconds);
 }
Ejemplo n.º 5
0
 protected IEnumerator InvokeEnter(BaseScene scene, params object[] args)
 {
     scene.isActive = true;
     yield return(scene.OnEnter(args));
 }
Ejemplo n.º 6
0
 protected string GetURL(BaseScene scene)
 {
     return(scene.url);
 }