Exemplo n.º 1
0
 public void Close(Type type)
 {
     if (UIResouces.ContainsKey(type))
     {
         UIElment info = UIResouces[type];
         if (info.Cache)
         {
             info.Instance.SetActive(false);
         }
         else
         {
             GameObject.Destroy(info.Instance);
             info.Instance = null;
         }
     }
 }
Exemplo n.º 2
0
        public T Show <T>()
        {
            Type type = typeof(T);

            if (UIResouces.ContainsKey(type))
            {
                UIElment info = UIResouces[type];
                if (info.Instance == null)
                {
                    UnityEngine.Object prefab = Resources.Load(info.Resouce);
                    if (prefab == null)
                    {
                        return(default(T));//返回 T 的默认值
                    }
                    info.Instance = (GameObject)GameObject.Instantiate(prefab);
                }
                else
                {
                    info.Instance.SetActive(true);
                }
                return(info.Instance.GetComponent <T>());
            }
            return(default(T));
        }