示例#1
0
        private MultipleObjectPool CreateSpawnObjectPool()
        {
            var objectContainer = new GameObject("ObjectPool");

            objectContainer.transform.SetParent(transform);

            int objectTypes   = objectSpawnSettings.resources.Count;
            var objectPrefabs = new List <GameObject>();

            for (int i = 0; i < objectTypes; i++)
            {
                GameObject objectPrefab = objectSpawnSettings.resources[i].prefab;
                objectPrefabs.Add(objectPrefab);
            }

            var objectPool = new MultipleObjectPool(objectPrefabs, objectContainer.transform, 300);

            objectPool.CreatePool();

            return(objectPool);
        }
示例#2
0
        private MultipleObjectPool CreateTreePool()
        {
            var treeContainer = new GameObject("TreePool");

            treeContainer.transform.SetParent(transform);

            int treeTypes   = treeSpawnSettings.resources.Count;
            var treePrefabs = new List <GameObject>();

            for (int i = 0; i < treeTypes; i++)
            {
                GameObject treePrefab = treeSpawnSettings.resources[i].prefab;
                treePrefabs.Add(treePrefab);
            }

            var treePool = new MultipleObjectPool(treePrefabs, treeContainer.transform, 300);

            treePool.CreatePool();

            return(treePool);
        }