/// <summary> /// 出池子 /// 约定 UI 的Item预制体都放到 Resources/ItemPrefabs文件夹下 /// 约定 UI 的Item预制体和脚本名字保持一致 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public T Dequeue <T>() where T : ItemBase { T tmp = pool.Dequeue <T>(); if (tmp == null) { T oo = Resources.Load <T>("ItemPrefabs/" + typeof(T).Name); tmp = GameObject.Instantiate(oo); tmp.name = tmp.name.Split('(')[0]; pool.AddPool(tmp); } return(tmp); }