Ejemplo n.º 1
0
        public UIManager()
        {
            GameObject obj = ResMgr.GetInstance().load <GameObject>("UI/Canvas");

            canvas = obj.transform as RectTransform;
            GameObject.DontDestroyOnLoad(obj);

            top    = canvas.Find("Top");
            mid    = canvas.Find("Mid");
            down   = canvas.Find("Down");
            system = canvas.Find("System");

            obj = ResMgr.GetInstance().load <GameObject>("UI/EventSystem");
            GameObject.DontDestroyOnLoad(obj);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获得对象池中的闲置对象
 /// </summary>
 /// <param name="name">地址</param>
 /// <returns></returns>
 public void GetObj(string name, UnityAction <GameObject> callback)
 {
     //GameObject obj = null;
     //判断缓存池中是否有缓存空间和闲置对象
     if (poolDic.ContainsKey(name) && poolDic[name].poolList.Count > 0)
     {
         //obj = poolDic[name].GetObj();
         callback?.Invoke(poolDic[name].GetObj());
     }
     else
     {
         ResMgr.GetInstance().loadAsync <GameObject>(name, (o) =>
         {
             o.name = name;
             callback?.Invoke(o);
         });
         //obj = GameObject.Instantiate(Resources.Load<GameObject>(name));
     }
 }