Example #1
0
    /// <summary>
    /// 创建子窗口(非WndRoot下{直接挂在窗口里}))
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="strDialogIDD">窗口ID</param>
    /// <param name="parent">父节点</param>
    /// <returns></returns>
    private static T CreateWnd <T>() where T : WndBase
    {
        string strDialogIDD = typeof(T).ToString();

        if (strDialogIDD == WndBase.WndIDD())
        {
            return(default(T));
        }

        GameObject go = NDLoad.LoadWnd(strDialogIDD, g_tWndRoot) as GameObject;

        if (go == null)
        {
            Debug.Log("WndManager CreateWnd " + strDialogIDD + "  not found ! ");
            return(default(T));
        }
        else
        {
            T wndDialog = go.GetComponent <T> ();
            if (wndDialog != null)
            {
                wndDialog.WndStart();
                m_lwnd.Add(wndDialog);
                return(wndDialog);
            }
            else
            {
                Debug.Log(strDialogIDD + "  no add wnd component ! ");
                GameObject.Destroy(go);
            }
            return(default(T));
        }
    }
Example #2
0
    /// <summary>
    /// 创建子窗口(非WndRoot(这下面挂载UI界面)下)
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="strDialogIDD">窗口ID</param>
    /// <param name="parent">父节点</param>
    /// <returns></returns>
    public static T CreateDialog <T>(Transform parent) where T :
    WndBase
    {
        string strDialogIDD = typeof(T).ToString();

        if (strDialogIDD == WndBase.DialogIDD())
        {
            return(default(T));
        }

        GameObject go = NDLoad.LoadWnd(strDialogIDD, parent) as GameObject;

        if (go == null)
        {
            Debug.Log("WndManager CreateDialog " + strDialogIDD + "  not found ! ");
            return(default(T));
        }
        else
        {
            T wndDialog = go.GetComponent <T> ();
            if (wndDialog != null)
            {
                wndDialog.WndStart();
                m_lwnd.Add(wndDialog);
                return(wndDialog);
            }
            else
            {
                wndDialog = go.AddComponent <T> ();
                if (wndDialog != null)
                {
                    wndDialog.WndStart();
                    m_lwnd.Add(wndDialog);
                }

                return(wndDialog);
            }
        }
    }