Ejemplo n.º 1
0
        public PoolObject GetObjectFromPool(PoolObjectType poolObjectType_, Vector3 position_, Quaternion rotation_)
        {
            PoolObject poolObject = poolObjectType_._objectPool.GetObjectFromPool(poolObjectType_, position_, rotation_);

            if (poolObject == null)
            {
                Debug.LogError(poolObjectType_.name + " not found!");
            }
            return(poolObject);
        }
Ejemplo n.º 2
0
        public Pool(PoolObjectType poolObjectType_, PoolObject poolObjectPrefab_, int initialCount_, bool fixedSize_, Transform parent_, ObjectPool objectPool_)
        {
            this._poolObjectType             = poolObjectType_;
            this._poolObjectType._objectPool = objectPool_;
            this._poolObjectPrefab           = poolObjectPrefab_;
            this._poolSize  = initialCount_;
            this._fixedSize = fixedSize_;

            //populate the pool
            for (int index = 0; index < initialCount_; index++)
            {
                AddObjectToPool(NewObjectInstance(parent_));
            }
        }
Ejemplo n.º 3
0
        private void CheckForDuplicatePoolNames()
        {
            for (int index = 0; index < _poolInfo.Length; index++)
            {
                PoolObjectType poolObjectType = _poolInfo[index]._poolObjectType;

                for (int internalIndex = index + 1; internalIndex < _poolInfo.Length; internalIndex++)
                {
                    if (poolObjectType.Equals(_poolInfo[internalIndex]._poolObjectType))
                    {
                        Debug.LogError(string.Format("Pool {0} & {1} have the same name. Assign different names.", index, internalIndex));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public PoolObject GetObjectFromPool(PoolObjectType poolObjectType_, Vector3 position_, Quaternion rotation_)
        {
            PoolObject result = null;

            if (_poolDictionary.ContainsKey(poolObjectType_))
            {
                Pool pool = _poolDictionary[poolObjectType_];
                result = pool.NextAvailableObject(position_, rotation_, PoolManager._instance.transform);
                if (result == null)
                {
                    Debug.LogWarning("No object available in pool. Consider setting fixedSize to false.: " + poolObjectType_);
                }
            }
            else
            {
                Debug.LogError("Invalid pool name specified: " + poolObjectType_);
            }

            return(result);
        }