/// <summary> /// 将一个界面!!![组合]!关闭! 除非特别了解已经确定,否则不建议使用。 建议使用SwitchToUI接口 by吴江 /// </summary> /// <param name="_type"></param> public void CloseGUI(GUIType _type) { List <string> needlist = GetUIByType(_type); foreach (var item in needlist) { if (uiDictionary.ContainsKey(item) && uiDictionary[item] != null) { GUIBase gui = uiDictionary[item]; gui.CloseUI(); } isClosingWnd = true; } }
/// <summary> /// 将一个界面实例从内存中释放 by吴江 /// </summary> /// <param name="_type"></param> public void ReleaseGUI <T>(string _name = "") where T : GUIBase { if (_name != "") { if (uiDictionary.ContainsKey(_name)) { GUIBase gui = uiDictionary[_name]; uiDictionary[_name] = null; uiDictionary.Remove(_name); if (gui != null) { gui.CloseUI(); DestroyImmediate(gui.gameObject, true); DestroyImmediate(gui, true); isClosingWnd = true; } } } else { T gui = null; foreach (GUIBase instance in uiDictionary.Values) { gui = instance as T; if (gui != null) { break; } } if (gui != null) { string name = gui.name; if (uiDictionary.ContainsKey(name)) { uiDictionary[name] = null; uiDictionary.Remove(name); } if (gui != null) { gui.CloseUI(); DestroyImmediate(gui.gameObject, true); DestroyImmediate(gui, true); isClosingWnd = true; } } } }
/// <summary> /// 将一个界面!!![组合]!!!实例从内存中释放 by吴江 /// </summary> /// <param name="_type"></param> public void ReleaseGUI(GUIType _type) { List <string> needlist = GetUIByType(_type); for (int i = 0; i < needlist.Count; i++) { string name = needlist[i]; if (uiDictionary.ContainsKey(name) && uiDictionary[name] != null) { GUIBase gui = uiDictionary[name]; gui.CloseUI(); uiDictionary[name] = null; uiDictionary.Remove(name); DestroyImmediate(gui.gameObject, true); DestroyImmediate(gui, true); isClosingWnd = true; } } }
/// <summary> /// 关闭所有界面,同时不播主界面缩放动画 /// </summary> public void CloseAllNoAnimation() { List <string> needReleaseList = new List <string>(); foreach (var item in uiDictionary.Keys) { if (uiDictionary[item].MutualExclusion) { needReleaseList.Add(item); } } for (int i = 0; i < needReleaseList.Count; i++) { string item = needReleaseList[i]; GUIBase gui = uiDictionary[item]; gui.CloseUI(); uiDictionary[item] = null; uiDictionary.Remove(item); DestroyImmediate(gui.gameObject, true); DestroyImmediate(gui, true); } isClosingWnd = true; }
/// <summary> /// 跳转至某个功能的UI组 by吴江 /// </summary> /// <param name="_type"></param> public void SwitchToUI(GUIType _type, GUIType _baseOn = GUIType.NONE) { if (!CheckFunction(_type)) { GameCenter.messageMng.AddClientMsg(389);//功能未开启 return; } CurOpenType = _type; CurBaseOnType = _baseOn; List <string> baseList = null; if (_baseOn != GUIType.NONE) { baseList = GetUIByType(_baseOn); } List <string> needReleaseList = new List <string>(); foreach (var item in uiDictionary.Keys) { if (baseList != null && baseList.Contains(item)) { continue; //如果有依赖背景窗口的话,那么依赖背景窗口逃避互斥 by吴江 } if (uiDictionary[item].MutualExclusion) { needReleaseList.Add(item); } } List <string> needopenlist = GetUIByType(_type); for (int i = 0; i < needReleaseList.Count; i++) { string item = needReleaseList[i]; if (!needopenlist.Contains(item)) { GUIBase gui = uiDictionary[item]; gui.CloseUI(); uiDictionary[item] = null; uiDictionary.Remove(item); DestroyImmediate(gui.gameObject, true); DestroyImmediate(gui, true); } } for (int i = 0; i < needopenlist.Count; i++) { string item = needopenlist[i]; if (uiDictionary.ContainsKey(item) && uiDictionary[item] != null) { if (uiDictionary[item].isActiveAndEnabled) { uiDictionary[item].CloseUI(); } uiDictionary[item].OpenUI(_baseOn); SetCompareTop(_type, _baseOn); if (uiDictionary[item].MutualExclusion) { CurOpenType = _type; CurMutualExclusionType = _type; } } else { GenGUI(item, true, SubGUIType.NONE, _baseOn, (x) => { SetCompareTop(_type, _baseOn); if (x.MutualExclusion) { CurOpenType = _type; CurMutualExclusionType = _type; } }); } } isClosingWnd = true; }