示例#1
0
文件: UIManager.cs 项目: xxxxp/Game
    public void CreatePanel <T>(string path) where T : UIBase
    {
        GameObject ass = ResourcesMgr.GetAsset <GameObject>(path);
        GameObject go  = GameObject.Instantiate(ass);

        go.AddComponent <T>();
        go.transform.SetParent(uiCanvas.transform);
        RectTransform rt = go.transform as RectTransform;

        rt.localPosition = Vector3.zero;
        rt.localScale    = Vector3.one;
        rt.sizeDelta     = Vector2.zero;
        go.name          = typeof(T).ToString();
    }
示例#2
0
    public void CreateChildPanel <T>(string childName, string path) where T : UIBase
    {
        GameObject ass = ResourcesMgr.GetAsset <GameObject>(path);
        GameObject go  = GameObject.Instantiate(ass);

        go.AddComponent <T>();
        Transform parentTr = transform;

        if (uicomponents.ContainsKey(childName))
        {
            parentTr = uicomponents[childName].transform;
        }
        go.transform.SetParent(parentTr);
        RectTransform rt = go.transform as RectTransform;

        rt.localPosition = Vector3.zero;
        rt.localScale    = Vector3.one;
        rt.sizeDelta     = Vector2.zero;
        go.name          = typeof(T).ToString();
    }