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); } 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); }
protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null) { // Check the window control state if (!this.IsWindowInControl(id)) { Debuger.Log("## UIManager has no control power of " + id.ToString()); return(null); } // If the window in shown list just return if (dicShownWindows.ContainsKey((int)id)) { return(null); } UIBaseWindow baseWindow = GetGameWindow(id); // If window not in scene start Instantiate new window to scene bool newAdded = false; if (!baseWindow) { newAdded = true; if (UIResourceDefine.windowPrefabPath.ContainsKey((int)id)) { string prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[(int)id]; GameObject prefab = Resources.Load <GameObject>(prefabPath); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); NGUITools.SetActive(uiObject, true); // NOTE: You can add component to the window in the inspector // Or just AddComponent<UIxxxxWindow>() to the target baseWindow = uiObject.GetComponent <UIBaseWindow>(); if (baseWindow.ID != id) { Debuger.LogError(string.Format("<color=cyan>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id)); return(null); } // Get the window target root parent Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType); GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform); dicAllWindows[(int)id] = baseWindow; } } } if (baseWindow == null) { Debuger.LogError("[window instance is null.]" + id.ToString()); } // Call reset window when first load new window // Or get forceResetWindow param if (newAdded || (showData != null && showData.forceResetWindow)) { baseWindow.ResetWindow(); } if (showData == null || (showData != null && showData.executeNavLogic)) { // refresh the navigation data ExecuteNavigationLogic(baseWindow, showData); } // Adjust the window depth AdjustBaseWindowDepth(baseWindow); // Add common background collider to window AddColliderBgForWindow(baseWindow); return(baseWindow); }