November 2019
Intermediate to advanced
404 pages
12h 9m
English
Finally, there is the act of despawning the objects. As mentioned previously, this primarily involves deactivating the object, but we also need to take care of various bookkeeping tasks and invoking Despawned() on all of its IPoolableComponent references.
Here is the method definition for PrefabPool.Despawn():
public bool Despawn(GameObject objToDespawn) { if (!_activeList.ContainsKey(objToDespawn)) { Debug.LogError ("This Object is not managed by this object pool!"); return false; } PoolablePrefabData data = _activeList[objToDespawn]; for(int i = 0; i < data.poolableComponents.Length; ++i) { data.poolableComponents[i].Despawned (); } data.go.SetActive (false); _activeList.Remove (objToDespawn); _inactiveList.Enqueue(data); ...Read now
Unlock full access