Ejemplo n.º 1
0
        public static PoolGameObject RequestPoolGameObject(GameObject prefab, Vector3 pos)
        {
            Instance.CreatePool();
            PoolGameObject temp = GetFromPool(prefab.name);

            if (temp == null)
            {
                GameObject go = GameObject.Instantiate(prefab);
                if (!go.HadComponent <PoolGameObject>())
                {
                    temp = go.AddComponent <PoolGameObject>();
                }
                else
                {
                    temp = go.GetComponent <PoolGameObject>();
                }
                temp.transform.position = pos;
                temp.SetParent(Instance.pool.transform);
            }

            Instance.SavePoolGameObject(prefab.name, temp);

            return(temp);
        }
Ejemplo n.º 2
0
        public static PoolGameObject RequestPoolGameObject(GameObject prefab, Vector3 pos)
        {
            Instance.CreatePool();
            PoolGameObject temp = GetFromPool(prefab.name);

            if (temp == null)
            {
                GameObject go = GameObject.Instantiate(prefab);
                if (!go.HadComponent <PoolGameObject>())
                {
                    temp = go.AddComponent <PoolGameObject>();
                }
                else
                {
                    temp = go.GetComponent <PoolGameObject>();
                }
                temp.transform.position = pos;
                temp.SetParent(Instance.pool.transform);
                if (!Instance.mPool.ContainsKey(prefab.name))
                {
                    Instance.mPool.Add(prefab.name, new Queue <PoolGameObject>());
                }
            }

            if (Instance.mPool[prefab.name].Count < Config.PoolCount)
            {
                Instance.mPool[prefab.name].Enqueue(temp);
            }
            else
            {
                Debug.LogWarning("The Pool is Less then PoolCount.Don't Save it.");
            }


            return(temp);
        }
Ejemplo n.º 3
0
        public PoolGameObject RequestPoolGameObject(GameObject prefab, Vector3 pos)
        {
            CreatePool();
            PoolGameObject temp = GetFromPool(prefab.name);

            if (temp == null)
            {
                GameObject go = GameObject.Instantiate(prefab);
                if (!go.HadComponent <PoolGameObject>())
                {
                    temp = go.AddComponent <PoolGameObject>();
                }
                else
                {
                    temp = go.GetComponent <PoolGameObject>();
                }
                temp.transform.position = pos;
                temp.SetParent(pool.transform);
                if (!mPool.ContainsKey(prefab.name))
                {
                    mPool.Add(prefab.name, new Queue <PoolGameObject>());
                }
            }

            if (mPool[prefab.name].Count < Config.PoolCount)
            {
                mPool[prefab.name].Enqueue(temp);
            }
            else
            {
                Debug.Log();
            }


            return(temp);
        }
Ejemplo n.º 4
0
 public static void SavePoolGameObject(string name, PoolGameObject poolGameObject)
 {
     if (!Instance.mPool.ContainsKey(name))
     {
     }
 }
Ejemplo n.º 5
0
 public static void SavePoolGameObject(string name, PoolGameObject poolGameObject)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 移除对象
 /// </summary>
 public void RemoveObject(PoolGameObject obj)
 {
 }
Ejemplo n.º 7
0
 public static void SetParent(this PoolGameObject poolGameObject, Transform parent)
 {
     poolGameObject.gameObject.SetParent(parent);
 }
Ejemplo n.º 8
0
 public static void Reset(this PoolGameObject poolGameObject)
 {
     poolGameObject.gameObject.Reset();
 }
Ejemplo n.º 9
0
 public static void Hide(this PoolGameObject poolGameObject)
 {
     poolGameObject.gameObject.Hide();
 }
Ejemplo n.º 10
0
 public static void Show(this PoolGameObject poolGameObject)
 {
     poolGameObject.gameObject.Show();
 }
Ejemplo n.º 11
0
 public void SaveGameObject(PoolGameObject poolGameObject)
 {
 }