IEnumerator _EnterScene(int sceneID) { var newBehavior = GetBehavior(sceneID); var new_sceneBase = DB.SceneBaseMap[sceneID]; if (_cur_behavior != newBehavior) { //退出当前玩法 _cur_behavior?.LeaveBehavior(); _last_behavior = _cur_behavior; _cur_behavior = newBehavior; } if (sceneID != _cur_scene_id) { _cur_behavior?.LeaveScene(); _last_scene_id = _cur_scene_id; _cur_scene_id = sceneID; //加载新场景 yield return(GameMng.instance.StartCoroutine(BuildScene(new_sceneBase))); } //初始化 InitScene(new_sceneBase); _cur_behavior.InitBehavior(); _cur_behavior.InitScene(); //进入 _cur_behavior.EnterBehavior(); _cur_behavior.EnterScene(); yield return(null); }
IEnumerator _EnterScene(int sceneID) { var newBehavior = GetBehavior(sceneID); if (newBehavior == null) { yield break; } if (curScene != null) { curScene.LeaveScene(); //销毁上一个场景 if (model.Cur_Data != null && tf_parent) { var last = tf_parent.gameObject.FindChild(model.Cur_Data.name); GameObject.Destroy(last); } } //加载新场景 if (!DB.SceneBaseMap.ContainsKey(sceneID)) { Log.Error($"sceneID:{sceneID} ,配置表中不存在"); yield break; } yield return(MyTask.Call(BuildScene(DB.SceneBaseMap[sceneID]))); curScene_id = sceneID; curScene = newBehavior; curScene.EnterScene(); }