/// <summary> /// 打开界面,已存在的界面则置顶显示 /// </summary> /// <param name="name">界面名</param> /// <param name="userData">用户自定义数据</param> public void OpenUI(string name, params object[] userData) { //检查是否处于场景销毁过程 SceneManager sceneManager = GameFramework.GetModule <SceneManager>(); if (sceneManager != null && sceneManager.IsDestroyingScene) { Debug.LogException(new InvalidOperationException("Scene being destroyed, operation invalid")); return; } //检查界面是否已存在 for (int i = m_Panels.Count - 1; i >= 0; --i) { BasePanel _panel = m_Panels[i]; if (_panel.UIName == name) { m_Panels.RemoveAt(i); m_Panels.Add(_panel); m_IsDirty = true; return; } } //创建新界面 Type type = Type.GetType(name); if (type == null) { //LuaPanel type = typeof(LuaPanel); } else if (type == typeof(LuaPanel)) { Debug.LogException(new NotSupportedException("Not Supported LuaPanel!")); return; } BasePanel panel = (BasePanel)Activator.CreateInstance(type); InvokeInit(panel, name); GameObject obj = InstantiatePanel(panel); m_Panels.Add(panel); InvokeAwake(panel, obj, userData); m_IsDirty = true; }
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()); } }