Skip to content

Commit

Permalink
Update ObjectPooler.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
ertanturan committed Mar 29, 2020
1 parent db90e58 commit d6349aa
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,19 @@ public GameObject SpawnFromPool(PooledObjectType tag, Vector3 pos, Quaternion ro
public void Despawn(GameObject obj)
{
PooledObjectType tag = obj.GetComponent<IPooledObject>().PoolType;
PoolDictionary[tag].Enqueue(obj);

IPooledObject iPooledObj = obj.GetComponent<IPooledObject>();
if (iPooledObj != null) iPooledObj.OnObjectDespawn();
obj.SetActive(false);
if (tag != null)
{
PoolDictionary[tag].Enqueue(obj);

IPooledObject iPooledObj = obj.GetComponent<IPooledObject>();
if (iPooledObj != null) iPooledObj.OnObjectDespawn();
obj.SetActive(false);
}
else
{
Debug.LogWarning("Trying to despawn object which is not pooled !");
}

}

Expand Down

0 comments on commit d6349aa

Please sign in to comment.