public static void destroyAllWindowsOnLoadScene(bool destroyAll = false) { foreach (KeyValuePair <string, UIResInfo> pair in m_resInfoDict) { UIResInfo resInfo = pair.Value; if (destroyAll == false) { UIResInfoAsset resInfoAsset = UIResInfoAssetAssetBundleReader.Instance.FindById(resInfo.name); if (resInfoAsset != null && resInfoAsset.wndType == (int)UI3WndType.Global) { continue; } } if (resInfo.objList.Count > 0) { UI3Wnd wnd = resInfo.objList[0].GetComponent <UI3Wnd>(); if (wnd != null && wnd.isDestroyOnLoadLevel == true) { for (int i = 0; i < resInfo.objList.Count; i++) { if (resInfo.objList[i] != null) { NGUITools.Destroy(resInfo.objList[i]); resInfo.objList[i] = null; } } PopBack(resInfo.name); resInfo.objList.Clear(); resInfo.prefab = null; } } } Resources.UnloadUnusedAssets(); }
public static UnityEngine.Object loadWindowRes(string className) { UIResInfo uiResInfo = null; if (m_resInfoDict.TryGetValue(className, out uiResInfo)) { //return ResManager.Instance.LoadPrefab(uiResInfo.resName); } return(null); }
private void SetupWnd(string name, string resPath, int wndType = 0, string layerType = "") { UIResInfo uiResInfo = new UIResInfo(); uiResInfo.name = name; uiResInfo.type = (UI3WndType)wndType; uiResInfo.layerType = string.IsNullOrEmpty(layerType) == true?UI3WndPanelLayerType.DefaultLayer.ToString() : layerType; uiResInfo.resName = resPath; m_resInfoDict[uiResInfo.name] = uiResInfo; }
public static UI3Wnd createWindow(string className) { UI3Wnd window = findWindow(className); if (window != null) { return(window); } GameObject res = loadWindowRes(className) as GameObject; if (res == null) { return(null); } GameObject parent = getWndRootPanel(className); GameObject uiGo = NGUITools.AddChild(parent, res); UIAnchor[] Anchor = uiGo.GetComponentsInChildren <UIAnchor>(true); for (int i = 0; i < Anchor.Length; ++i) { if (Anchor[i].uiCamera == null) { Anchor[i].uiCamera = Unity3Tools.FindInParent <Camera>(uiGo); } } uiGo.SetActive(false); window = uiGo.AddMissingComponent <UI3Wnd>(); int layerDepth = 0; UI3WndPanelLayerType layerType = (UI3WndPanelLayerType)Enum.Parse(typeof(UI3WndPanelLayerType), window.panelLayerType); if (UI3WndPanelLayer.layers.Length > (int)layerType) { layerDepth = UI3WndPanelLayer.layers[(int)layerType].begin; } window.addDepth(layerDepth); UIResInfo resInfo = m_resInfoDict[className]; if (resInfo != null) { window.WndType = resInfo.type; resInfo.objList.Add(uiGo); } window.ClassMark = resInfo.uiMark; return(window); }
// 创建 public static T createWindow <T>(GameObject parent, bool bSingle) where T : UI3Wnd { if (bSingle) { T window = findWindow <T>(); if (window != null) { return(window); } } GameObject res = loadWindowRes <T>() as GameObject; if (res == null) { return(null); } GameObject uiGo = NGUITools.AddChild(parent, res); UIAnchor[] Anchor = uiGo.GetComponentsInChildren <UIAnchor>(true); for (int i = 0; i < Anchor.Length; ++i) { if (Anchor[i].uiCamera == null) { Anchor[i].uiCamera = Unity3Tools.FindInParent <Camera>(uiGo); } } uiGo.SetActive(false); T t = uiGo.AddMissingComponent <T>(); string className = typeof(T).ToString(); UIResInfo resInfo = m_resInfoDict[className]; if (resInfo != null) { t.WndType = resInfo.type; t.panelLayerType = resInfo.layerType; resInfo.objList.Add(uiGo); } ((UI3Wnd)t).ClassMark = resInfo.uiMark; return(t); }
public static void ClearUIByLayerType(UI3WndPanelLayerType type) { foreach (KeyValuePair <string, UIResInfo> pair in m_resInfoDict) { UIResInfo resInfo = pair.Value; for (int i = 0; i < resInfo.objList.Count; i++) { if (resInfo.objList[i] != null && resInfo.layerType == type.ToString()) { NGUITools.Destroy(resInfo.objList[i]); resInfo.objList[i] = null; resInfo.objList.Clear(); resInfo.prefab = null; } } } ClearStack(type); }