示例#1
0
        private static Transform GetPoolTagTransform(PoolTag poolTag)
        {
            var rootPool = (GameObject.Find("[POOL]") ?? new GameObject("[POOL]")).transform;
            var pool     = new GameObject(poolTag.ToString());

            pool.transform.parent = rootPool;
            return(pool.transform);
        }
示例#2
0
        public GameObject Spawn(PoolTag tag, Vector3 position = default)
        {
            if (!poolGroup.ContainsKey(tag))
            {
                Debug.LogError($"PoolTag of type {tag.ToString()} doesn't exist!");
                return(null);
            }

            GameObject objectToSpawn = poolGroup[tag].Dequeue();

            objectToSpawn.SetActive(true);
            objectToSpawn.transform.position = position;
            objectToSpawn.transform.rotation = Quaternion.identity;

            poolGroup[tag].Enqueue(objectToSpawn);

            return(objectToSpawn);
        }