Skip to content

Woreira/Unity-Simple-Pooling-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Unity Simple Pooling System

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 by PoolManager.Allocate(), and the same goes for Destroy() and PoolManager.Deallocate()

Usage

  • Allocate from the pool using PoolManager.Allocate(), in place of instantiate, no need for those pesky pool managing things or convoluted calls:
  • Allocation Example
  • Deallocate from the pool using PoolManager.Deallocate():
  • Deallocation Example
  • Use PoolManager.ClearAllPools() to clear all pools (duh), it calls PoolManager.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!

About

A simple, easy to implement pooling system for unity

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages