Exemple #1
0
    private GameObject OpenWnd(string WndName, int type, out bool isNewWnd, bool isPreload = false)
    {
        WndAttribute OutWnd = null;

        if (!mWindowDic.TryGetValue(WndName, out OutWnd))
        {
            UnityEngine.Object o  = Resources.Load("Windows/" + WndName);
            GameObject         go = GameObject.Instantiate(o) as GameObject;
            go.name = WndName;
            go.transform.SetParent(mWindowRoot.transform);
            go.name = WndName;
            go.transform.transform.localPosition = new Vector3(0, 0, go.transform.position.z);
            go.transform.transform.localScale    = Vector3.one;
            go.SetActive(!isPreload);
            //加入窗口管理中
            OutWnd = WndAttribute.Create(WndName, type, go);
            mWindowDic.Add(WndName, OutWnd);
            isNewWnd = true;
            return(go);
        }
        else
        {
            OutWnd.WndObj.gameObject.SetActive(true);
            isNewWnd = false;
        }

        return(OutWnd.WndObj);
    }
Exemple #2
0
    public static T OpenWindow <T>(WndAttribute attr, out bool isNewWnd) where T : class
    {
        T          t  = null;
        GameObject ob = WindowsManager.OpenWindow(attr.WndName, attr.WndType, out isNewWnd);

        if (ob != null)
        {
            t = ob.GetComponent <T>();
            return(t);
        }
        return(t);
    }
Exemple #3
0
    private GameObject GetWindowObj(string wndName)
    {
        WndAttribute OutWnd = null;

        if (mWindowDic.TryGetValue(wndName, out OutWnd))
        {
            GameObject go = OutWnd.WndObj;
            return(go);
        }

        return(null);
    }
Exemple #4
0
    private bool CloseWnd(string WndName)
    {
        WndAttribute OutWnd = null;

        if (mWindowDic.TryGetValue(WndName, out OutWnd))
        {
            GameObject go = OutWnd.WndObj;
            if (go != null)
            {
                if (go.activeSelf)
                {
                    go.gameObject.SetActive(false);
                }
                //删除窗口
                mWindowDic.Remove(WndName);
                GameObject.Destroy(go);
            }
        }

        return(true);
    }