Ejemplo n.º 1
0
    public PlayerPool RequestPoolable()
    {
        if (this.HasObjectAvailable(1))
        {
            PlayerPool poolableObject = this.availableObjects [this.availableObjects.Count - 1];
            poolableObject.SetPoolRef(this);
            this.availableObjects.RemoveAt(this.availableObjects.Count - 1);
            this.usedObjects.Add(poolableObject);

            poolableObject.gameObject.SetActive(true);
            poolableObject.OnActivate();
            return(poolableObject);
        }
        else
        {
            Debug.LogError("[GameObjectPool] No more poolable object available!");
            return(null);
        }
    }