欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

2019.4.18第一个博客...

程序员文章站 2024-03-04 20:23:06
...

2019.4.18-第一个博客…

今天所学知识…

Unity中使用NGUI完善场景,编译脚本…

2019.4.18第一个博客...

public class UIWindowMgrr
{ 
public Dictionary<string, GameObject> uiWindowPareab = new Dictionary<string,
GameObject>();
public GameObject OpenWindow(string path, Transform parent)
{
    GameObject uiWindow = null;
    if (uiWindowPareab.ContainsKey(path))//判断当前键里是否有值
    {
        uiWindow = uiWindowPareab[path];
        uiWindow.SetActive(true); 
    }
    else
    {
        uiWindow = GameObject.Instantiate(Resources.Load(path)) as GameObject;
        uiWindow.SetActive(false);
        uiWindow.transform.parent = parent;//找到父节点并挂载
        uiWindow.transform.localPosition = Vector3.zero;
        uiWindow.transform.localRotation = Quaternion.Euler(Vector3.zero);
        uiWindow.transform.localScale = Vector3.one;
        uiWindowPareab.Add(path, uiWindow);
        uiWindow.SetActive(true);

    }
    return uiWindow;
}
}