Exemple #1
0
    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();
    }
Exemple #2
0
    /// <summary>
    /// 隐藏GrayScreen,
    /// </summary>
    /// <param name="wnd"></param>
    public static void HideGrayScreen(UI3Wnd wnd)
    {
        if (wnd == null || wnd.gameObject == null || wnd.WndType != UI3WndType.PopUp || wnd.GetClassName() == "UIGrayScreen")
        {
            return;
        }
        UIGrayScreen grayWnd = findWindow <UIGrayScreen>();

        if (grayWnd == null)
        {
            return;
        }
        string           panelLayer = GetPanelLayer(wnd.GetClassName());
        UIStack <string> stack      = GetStackByPanelLayer(panelLayer);

        if (stack == null)
        {
            return;
        }
        UI3Wnd lastWnd = GetLastGrayScreen(stack);

        if (lastWnd == null)
        {
            grayWnd.setActive(false);
        }
        else
        {
            ShowGrayScreen(lastWnd);
        }
    }
Exemple #3
0
    /// <summary>
    /// 出栈需要返回界面(栈顶),显示界面,
    /// </summary>
    /// <param name="wnd"></param>
    public static void BackPopup(string name)
    {
        UI3WndType type = GetWndType(name);

        if (UI3WndType.ReturnFullScreen != type)
        {
            return;
        }
        UIStack <string> stack    = GetStackByWndName(name);
        string           lastName = Peek(stack);

        lastName = GetValid(lastName, false);
        stack.DisplayList();
        if (string.IsNullOrEmpty(lastName) == true)
        {
            return;
        }
        UI3Wnd wnd = createWindow(lastName);

        if (wnd == null)
        {
            return;
        }
        int index = stack.FindLastByName(GetValid(lastName, true));

        stack.PopAt(index);
        wnd.show();
        stack.DisplayList();
    }
Exemple #4
0
    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);
    }
Exemple #5
0
    public static GameObject getWndRootPanel(GameObject go)
    {
        if (go == null)
        {
            return(null);
        }
        UI3Wnd wnd = go.GetComponent <UI3Wnd>();

        if (wnd == null)
        {
            return(null);
        }

        string wndName = wnd.GetClassName();;

        return(getWndRootPanel(wndName));
    }
Exemple #6
0
    /// <summary>
    /// 获取上一个Popup类型的界面,
    /// </summary>
    /// <param name="stack"></param>
    /// <returns></returns>
    public static UI3Wnd GetLastGrayScreen(UIStack <string> stack)
    {
        UI3Wnd        lastWnd = null;
        List <string> list    = stack.List;

        if (list != null || list.Count > 0)
        {
            for (int i = list.Count - 1; i >= 0; i--)
            {
                UI3Wnd curWnd = findWindow(list[i]);
                if (curWnd != null && curWnd.WndType == UI3WndType.PopUp && curWnd.gameObject.activeInHierarchy == true)
                {
                    return(lastWnd = curWnd);
                }
            }
        }
        return(lastWnd);
    }
Exemple #7
0
    /// <summary>
    /// 显示GrayScreen,
    /// </summary>
    /// <param name="wnd"></param>
    /// <param name="OnClickGrayScreen"></param>
    public static void ShowGrayScreen(UI3Wnd wnd, System.Action OnClickGrayScreen = null)
    {
        if (wnd == null || wnd.gameObject == null || wnd.WndType != UI3WndType.PopUp || wnd.GetClassName() == "UIGrayScreen")
        {
            return;
        }
        UIGrayScreen grayWnd = createWindow <UIGrayScreen>();

        if (grayWnd == null)
        {
            return;
        }
        grayWnd.OnClickEventCallback = OnClickGrayScreen != null ? OnClickGrayScreen : wnd.OnClickGrayScreen;
        grayWnd.Wnd = wnd.gameObject;
        int depth = wnd.getMinDepth();

        grayWnd.setDepth(depth - 1);
        grayWnd.setActive(true);
    }
Exemple #8
0
    public static void HideStackWindows(string layerType, string name = null)
    {
        UIStack <string> stack = GetStackByPanelLayer(layerType);

        if (stack == null)
        {
            return;
        }
        for (int i = 0; i < stack.List.Count; i++)
        {
            string strVal = stack.List[i];
            if (string.IsNullOrEmpty(name) == false && name.Equals(strVal))
            {
                continue;
            }
            UI3Wnd curWnd = findWindow(strVal);
            if (curWnd != null && curWnd.isHideOnFullScreen == true)
            {
                curWnd.hide();
            }
        }
    }
Exemple #9
0
    /// <summary>
    /// 根据不同layer,出栈,在获取上一个bringTop界面,在进行bringTop操作,
    /// 该方法只适用于ReturnFullScreen界面,
    /// </summary>
    /// <param name="name"></param>
    public static void PopBack(string name)
    {
        if (IsVaild(name, false) == false)
        {
            return;
        }
        string           panelLayer = GetPanelLayer(name);
        UIStack <string> stack      = GetStackByPanelLayer(panelLayer);

        if (stack == null)
        {
            return;
        }
        stack.DisplayList();

        int index = stack.FindFirstByName(name);

        if (index < 0)
        {
            return;
        }
        //if(CanPopBack(name,index,stack) == false)
        //    return;
        bool   isTop   = stack.IsTop(name);
        bool   isPopup = true;
        UI3Wnd wnd     = findWindow(name);

        if (wnd != null)
        {
            isPopup = wnd.isHideOnFullScreen;
        }
        if (isPopup == false)
        {
            return;
        }
        stack.PopAt(index);
    }