public void LoadSystemUI(GameResource.SystemUIType type, LoadMgr.AsyncCallback callback = null) { Transform transform = this.transform.parent.Find("System").GetComponent <Transform>(); //判断缓存中是否有存在对象 GameObject go; if (!SystemUIGODict.TryGetValue(type, out go)) { go = GameApp.Instance.ResourceMngr.InstantiateGameObject( GameResource.UIResourcePath + GameData.Instance.SystemDict[type], null, Vector3.zero); SystemUIGODict.Add(type, go); } else { go.transform.SetAsLastSibling(); go.SetActive(true); } for (int i = 0; i < systemUIList.Count; i++) { if (systemUIList[i] == type) { systemUIList.RemoveAt(i); break; } } //将队列显示放到最后一位 systemUIList.Add(type); }
/// <summary> /// 关闭系统UI /// </summary> /// <param name="type"></param> public void CloseSystemUI(GameResource.SystemUIType type = GameResource.SystemUIType.NULL, LoadManager.CallBack call = null) { //如果当前没有页面显示,则直接返回 if (SystemList.Count <= 0) { return; } //如果直接关闭当前最前一层UI if (type == GameResource.SystemUIType.NULL) { GameObject go; if (!SystemUICache.TryGetValue(SystemList[SystemList.Count - 1], out go)) { return; } go.SetActive(false); SystemList.RemoveAt(SystemList.Count - 1); } else { //关闭制定UI页面 GameObject go; if (!SystemUICache.TryGetValue(type, out go)) { return; } go.SetActive(false); //将UI页面从队列中剔除 for (int i = 0; i < SystemList.Count; i++) { if (SystemList[i] == type) { SystemList.RemoveAt(i); break; } } } if (call != null) { call(); } }
public void CloseSystemUI(GameResource.SystemUIType type = GameResource.SystemUIType.Null, LoadMgr.AsyncCallback callback = null) { if (systemUIList.Count <= 0) { return; } ; if (type == GameResource.SystemUIType.Null) { GameObject go; if (SystemUIGODict.TryGetValue(systemUIList[systemUIList.Count - 1], out go)) { return; } go.SetActive(false); systemUIList.RemoveAt(systemUIList.Count - 1); } else { GameObject go; if (!SystemUIGODict.TryGetValue(type, out go)) { return; } ; go.SetActive(false); //将UI界面从队列中移除 for (int i = 0; i < systemUIList.Count; i++) { if (systemUIList[i] == type) { systemUIList.RemoveAt(i); break; } } } if (callback != null) { callback(); } }
/// <summary> /// 加载系统UI /// </summary> /// <param name="type"></param> /// <param name="call"></param> public void LoadSystemUI(GameResource.SystemUIType type, LoadManager.CallBack call = null) { //设置父对象为system Transform tfp = transform.parent.Find("system"); GameObject go; //尝试获取缓存中是否含有加载对象 if (!SystemUICache.TryGetValue(type, out go)) { //如果没有,则加载生成之后,将页面对象添加到缓存中 string path = GameResource.UIResourcePath + GameData.Instance.SystemUI[type]; go = GameApp.Instance.ResourcesManagerScript.LoadInstantiateGameObject(path, tfp, Vector3.zero); SystemUICache.Add(type, go); } else { //否则直接将该页面调至最前并显示出来 go.transform.SetAsLastSibling(); go.SetActive(true); } //如果当前队列中该页面已经显示,则在队列中剔除 for (int i = 0; i < SystemList.Count; i++) { if (SystemList[i] == type) { SystemList.RemoveAt(i); break; } } //将页面显示添加在队列最后一位 SystemList.Add(type); if (call != null) { call(); } }