private void RealShow(WindowID windowId, bool bAppend) { string wndPath = wndResDict [windowId]; string panelPath = string.Format("{0}Panel/{1}", AssetDefine.ResRoot, windowId.ToString()); GameObject prefab = ResourcesManager.Load <GameObject>(panelPath); if (prefab != null) { GameObject clone = (GameObject)GameObject.Instantiate(prefab); XFramework.Utility.Util.AddChildToTarget(wndRoot.transform, clone.transform); UIWndBase wnd = clone.GetComponent <UIWndBase> (); wnd.status = WindowStatus.Active; if (curShowWnd != null) { wnd.preWndID = curShowWnd.wndID; } wnd.wndID = windowId; if (bAppend) { Log("push into stack " + curShowWnd.wndID.ToString()); if (backStack.Count == 0) { backStack.Push(curShowWnd); } curShowWnd = wnd; backStack.Push(curShowWnd); AdjustAlpha(); } else { curShowWnd = wnd; HideAllCach(); BreakBackStack(); } cacheWndDict.Add(windowId, curShowWnd); curShowWnd.AdjustAlpha(1.0f); CheckCach(); wnd.Refresh(); } }
/// <summary> /// 窗口显示,队列型加载 /// </summary> public void ShowWindow(WindowID windowId, bool bAppend = false) { if (instance == null) { Init(); } if (FrameRoot == null) { GameObject prefab = ResourcesManager.Load <GameObject>("BuildIn/Frame/UIFrame"); FrameRoot = Util.NewGameObject(prefab, wndRoot).GetComponent <UIFrame>(); } FrameRoot.Init(windowId); if (wndResDict.ContainsKey(windowId)) { if (cacheWndDict.ContainsKey(windowId)) { UIWndBase wnd = cacheWndDict [windowId]; Log("缓存中, 状态是:" + wnd.status.ToString()); if (wnd.status == WindowStatus.Inactive) { if (bAppend) { if (backStack.Count == 0) { backStack.Push(curShowWnd); } backStack.Push(wnd); AdjustAlpha(); } else { HideAllCach(); BreakBackStack(); curShowWnd.Close(); } wnd.Show(); curShowWnd = wnd; } else if (wnd.status == WindowStatus.Gray) { curShowWnd.Close(); curShowWnd = wnd; backStack.Pop(); AdjustAlpha(); } else if (wnd.status == WindowStatus.Active) { Log("当前窗口已经是显示窗口"); } wnd.Refresh(); } else { Log("新加入窗口:" + windowId.ToString()); RealShow(windowId, bAppend); } } else { Log(windowId.ToString() + " 不存在资源"); } }