Example #1
0
        private IEnumerator DoInitSet(PoolingSet poolingSet)
        {
            if (!poolingSet.IsValid())
            {
                yield break;
            }

            _amount            = poolingSet.AmountToPool;
            poolingSet.Objects = new List <GameObject>(_amount);

            _hasFinishedCreatingSet = false;

            for (int j = 0; j < _amount; j++)
            {
                AddObjectToPoolingSet(poolingSet, j.ToString());
                if (_incrementalInitialization)
                {
                    yield return(null);
                }
            }

            if (!_poolingSets.Contains(poolingSet))
            {
                _poolingSets.Add(poolingSet);
            }

            _hasFinishedCreatingSet = true;
        }
Example #2
0
        public void AddPoolingSet(PoolingSet poolingSet)
        {
            if (!poolingSet.IsValid())
            {
                Debug.LogWarning("Set not valid!"); return;
            }
            if (!_hasInit || !_hasFinishedCreatingSet)
            {
                Debug.LogWarning("Another operation is still taking place."); return;
            }

            StartCoroutine(DoInitSet(poolingSet));
        }