예제 #1
0
    //如果不是特别“重”的常用窗口,尽量IsCache = false, 后台会帮你保留
    public static bool CreateWnd <T>(WndType wndtype, bool IsCache, bool async, WndCreateHook pfun) where T :
    WndBase
    {
        bool      ret     = false;
        string    WndName = typeof(T).ToString();
        Transform parent  = WndManager.GetWndParent(wndtype);

        // 已经存在
        T wnd = FindWnd <T>();

        if (wnd != null)
        {
            SetWndTop(wnd);
            //show the wnd
            wnd.ShowWnd(true);
            if (pfun != null)
            {
                pfun(wnd);
            }
            return(true);
        }
        // 不存在则创建了。
        ResourceManger.LoadWnd(WndName, parent, IsCache, async,
                               (g) =>
        {
            if (g != null)
            {
                wnd = g.GetComponent <T>
                          ();
                wnd.SetWndType(wndtype);
                AddWnd(wnd);
                if (pfun != null)
                {
                    pfun(wnd);
                }
                ret = true;
            }
        });
        return(ret);
    }