public void LoadCharacterScene(Action loaded, Action <int> process = null, bool CreateCharacter = false, bool hideReturnBtn = false) { Action action = () => { MogoGlobleUIManager.Instance.ShowWaitingTip(true); var serverInfo = SystemConfig.GetSelectedServerInfo(); if (CreateCharacter) { //NewLoginUIViewManager.Instance.ShowCreateCharacterUI(); //NewLoginUIViewManager.Instance.ShowCreateCharacterUIBackBtn(!hideReturnBtn); //if (serverInfo != null) // NewLoginUIViewManager.Instance.SetCreateCharacterServerBtnName(serverInfo.name); NewLoginUILogicManager.Instance.LoadCreateCharacter( () => { if (loaded != null) { loaded(); } NewLoginUIViewManager.Instance.ShowCreateCharacterUI(); NewLoginUIViewManager.Instance.ShowCreateCharacterUIBackBtn(!hideReturnBtn); if (serverInfo != null) { NewLoginUIViewManager.Instance.SetCreateCharacterServerBtnName(serverInfo.name); } //MogoMessageBox.HideLoading(); MogoGlobleUIManager.Instance.ShowWaitingTip(false); }); } else { NewLoginUIViewManager.Instance.ShowChooseCharacterUI(); //NewLoginUILogicManager.Instance.LoadChooseCharacterSceneAfterDelete(); if (serverInfo != null) { NewLoginUIViewManager.Instance.SetChooseCharacterServerBtnName(serverInfo.name); } if (loaded != null) { loaded(); } } }; MogoMessageBox.ShowLoading(); LoadScene(MogoWorld.globalSetting.chooseCharaterScene, (isLoadScene, data) => { if (isLoadScene) { if (LoginUIViewManager.Instance) { LoginUIViewManager.Instance.ReleaseUIAndResources(); } LoadMainUI(() => { MogoMessageBox.HideLoading(); MogoUIManager.Instance.ShowNewLoginUI(action); }); } else { MogoMessageBox.HideLoading(); action(); } }, MogoMessageBox.Loading, false); }
/// <summary> /// 加载场景。 /// </summary> /// <param name="id">场景标识</param> /// <param name="loaded">加载结束,参数为是否加载场景</param> /// <param name="needLoading">是否需要Loading界面</param> public void LoadScene(int id, Action <Boolean, MapData> loaded, Action <int> process = null, bool needLoading = true) { if (needLoading) { MogoMessageBox.ShowLoading(); } if (m_lastScene == id) { //Debug.Log("Same scene in LoadScene: " + id); if (loaded != null) { try { loaded(false, null); } catch (Exception ex) { Debug.LogException(ex); } if (needLoading) { MogoMessageBox.HideLoading(); } } return; } //使用资源监测,在卸载前打印场景所使用的资源出来 if (m_currentMap != null) { ResourceWachter.Instance.SceneID = id; } UnloadScene(() => { MapData data; bool flag = MapData.dataMap.TryGetValue(id, out data); if (!flag) { Debug.LogError("map_setting id not exist: " + id); if (loaded != null) { try { loaded(false, null); } catch (Exception ex) { Debug.LogException(ex); } if (needLoading) { MogoMessageBox.HideLoading(); } } return; } m_lastScene = id; m_currentMap = data; if (id == MogoWorld.globalSetting.loginScene) { EventDispatcher.TriggerEvent(SettingEvent.BuildSoundEnvironment, id); } Action loadScene = () => { LoadScene(data, (isLoadScene) => { //Debug.Log("RenderSettings: " + id); if (loaded != null) { try { if (process != null) { process(80); } if (MogoWorld.thePlayer != null) { MogoWorld.thePlayer.SetLightVisible(data.characherLight == GameData.LightType.Normal); } preloadResource(id, process, () => { if (process != null) { process(99); } loaded(isLoadScene, data); if (process != null) { process(100); } }); } catch (Exception ex) { Debug.LogException(ex); } } }, data.sceneName, process); }; if (MogoWorld.thePlayer != null) { MogoWorld.thePlayer.GotoPreparePosition(); //MogoWorld.thePlayer.AddCallbackInFrames(loadScene); } //else // loadScene(); loadScene(); //TimerHeap.AddTimer(500, 0, loadScene); }); }