protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id) { // 检测控制权限 if (!this.IsWindowInControl(id)) { Debug.Log("UIManager has no control power of " + id.ToString()); return(null); } if (ShownWindows.ContainsKey(id)) { return(null); } // 隐藏callWindowId指向窗口 /*if(showData != null) * HideWindow(showData.callWindowId, null);*/ UIBaseWindow baseWindow = GetGameWindow(id); bool newAdded = false; if (!baseWindow) { newAdded = true; // 窗口不存在从内存进行加载 if (AppConst.windowPrefabPath.ContainsKey(id)) { GameObject prefab = ResourcesMgr.Instance.LoadResource <GameObject>(ResourceType.RESOURCE_UI, AppConst.windowPrefabPath[id]); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); Util.SetActive(uiObject, true); baseWindow = uiObject.GetComponent <UIBaseWindow>(); Util.AddChildToTarget(UINormalWindowRoot, baseWindow.transform); AllWindows[id] = baseWindow; } } } if (baseWindow == null) { Debug.LogError("[window instance is null.]" + id.ToString()); return(null); } if (newAdded) { baseWindow.ResetWindow(); } //// 导航系统数据更新 //RefreshBackSequenceData(baseWindow); //// 调整层级depth //AdjustBaseWindowDepth(baseWindow); //// 添加背景Collider //AddColliderBgForWindow(baseWindow); return(baseWindow); }
protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null) { // 检测控制权限 if (!this.IsWindowInControl(id)) { Debug.Log("UIManager has no control power of " + id.ToString()); return(null); } if (shownWindows.ContainsKey(id)) { return(null); } // 隐藏callWindowId指向窗口 /*if(showData != null) * HideWindow(showData.callWindowId, null);*/ UIBaseWindow baseWindow = GetGameWindow(id); bool newAdded = false; if (!baseWindow) { newAdded = true; // 窗口不存在从内存进行加载 if (UIResourceDefine.windowPrefabPath.ContainsKey(id)) { string prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[id]; GameObject prefab = Resources.Load <GameObject>(prefabPath); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); NGUITools.SetActive(uiObject, true); baseWindow = uiObject.GetComponent <UIBaseWindow>(); // 需要动态添加对应的控制界面,prefab不用添加脚本 Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType); GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform); allWindows[id] = baseWindow; } } } if (baseWindow == null) { Debug.LogError("[window instance is null.]" + id.ToString()); } // 重置界面(第一次添加,强制Reset) if (newAdded || (showData != null && showData.forceResetWindow)) { baseWindow.ResetWindow(); } // 显示界面固定内容 // 导航系统数据更新 RefreshBackSequenceData(baseWindow); // 调整层级depth AdjustBaseWindowDepth(baseWindow); // 添加背景Collider AddColliderBgForWindow(baseWindow); return(baseWindow); }