/// <summary> /// 聚焦新场景 /// </summary> public void FocusBgScene() { this.ExitCurrent(); this.currScene = this.bgScene; SceneUIHelper.MainScene = this.currScene; }
public void Awake() { this.currScene = null; sceneBackStack = new List <int>(); //监听各种事件消息,触发各类方法,如重回成功 GAME_RELOGIN_FINISH //this.OnRelogin(); instance = this; }
/// <summary> /// 叠加场景 /// </summary> /// <param name="sceneID"></param> /// <param name="param"></param> public void LoadAdditiveScene(int sceneID, SceneParam param) { SceneBase newScene = this.CreateScene(sceneID); if (newScene == null) { return; } newScene.Load(param); this.bgScene = newScene; }
/// <summary> /// 生成一个SceneBase /// </summary> /// <param name="sceneID"></param> /// <returns></returns> public SceneBase CreateScene(int sceneID) { SceneConfig sceneConfig = SceneDefine.SceneConfig[sceneID]; if (sceneConfig == null) { Debug.Log("can not find scene config...SceneID:" + sceneID); return(null); } //新场景加载前的准备(应该根据类型实例化对应的场景类,需要反射调用) SceneBase newScene = new SceneBase(sceneConfig); return(newScene); }
/// <summary> /// 退出当前场景 /// </summary> /// <param name="sceneUIPush"></param> public void ExitCurrent(bool sceneUIPush = false) { if (this.currScene == null) { return; } int sceneID = this.currScene.GetSceneID(); SceneUIHelper.SceneExit(sceneID, sceneUIPush); this.currScene.Exit(); this.currScene.Dispose(); this.currScene = null; }
/// <summary> /// 根据场景ID加载新的场景 /// </summary> /// <param name="sceneID"></param> /// <param name="param"></param> /// <param name="onloaded"></param> /// <param name="isback"></param> /// <param name="sceneBackStackPush"></param> private void LoadScene(int sceneID, SceneParam param, Action onloaded, bool sceneUIPush, bool isback, bool sceneBackStackPush) { //新建下一个场景 SceneBase newScene = this.CreateScene(sceneID); if (newScene == null) { return; } int lastSceneId = this.GetSceneID(); if (sceneBackStackPush) { this.sceneBackStack.Add(lastSceneId); } //缷载旧的场景 this.lastSceenID = lastSceneId; SceneBase lastScene = this.currScene; if (lastScene != null) { string lastSceneName = lastScene.GetSceneName(); int lastSceneType = lastScene.GetSceneType(); //退出当前场景并通知UI关闭当前场景UI this.ExitCurrent(sceneUIPush); //清理当前场景缓存的对象,终止正在加载的队列 if (lastSceneType != newScene.GetSceneType()) { SceneUIHelper.UnloadSceneAB(lastSceneName, false); } SceneUIHelper.MainScene = null; SceneUIHelper.MainCamera = null; SceneUIHelper.SceneUIRoot = null; //除了登陆场景,其他场景切换均有场景过渡 if (lastSceneType != (int)SceneDefine.SceneType.LOGIN) { //如果参数里标记了使用CUTSCENE过渡,那么不要打开这个普通过渡 界面 bool useNormalTransition = true; if (param != null) { if (param.UseCutSceneTransition) { useNormalTransition = false; } else if (param.useCivSceneTransition) { useNormalTransition = false; //打开一个加载界面 } } if (useNormalTransition) { //打开正常的加载过渡界面 } } } this.currScene = newScene; //通知开始加载新场景 SceneUIHelper.MainScene = newScene; newScene.Load(param, onloaded, isback); //发送场景切换事件 }