An easy to implement pooling system. Meant for those "in hindsight I should have used that" moments. It uses dictionaries to keep track of the pools and the objects.
This was made as a "one size fits all approach" needless to say, it is faster than Instantiate-then-Destroy, but not as fast as a custom system.
The main purpose here is a system that works with minimal changes to the rest of the code,
Instantiate()
calls can be swapped easily byPoolManager.Allocate()
, and the same goes forDestroy()
andPoolManager.Deallocate()
- Allocate from the pool using
PoolManager.Allocate()
, in place of instantiate, no need for those pesky pool managing things or convoluted calls: - Deallocate from the pool using
PoolManager.Deallocate()
: - Use
PoolManager.ClearAllPools()
to clear all pools (duh), it callsPoolManager.Deallocate(
) on every pooled obj. This prevents bugs especially on scene changes and level wipes (like having to wipe all enemies from the scene on gameover, for example);
Liked the repo? Give it a star then!