Simple Pooling for Unity

I made a thing.  It might be helpful for people.

https://gist.github.com/quill18/5a7cfffae68892621267

Instantiating & Destroying large numbers of objects (bullets or large hordes of enemies) can sometimes cause a game to stutter during their creation or later during garbage collection.  Object Pooling counters this by simply deactivating objects instead of destroying them, then re-activating them when you need a new copy.

All the pooling solutions for Unity I could find seemed overwrought and often required a bunch of advanced setup on a prefab-by-prefab basis.  The solution I’ve come up with simply requires you to use SimplePool.Spawn() and SimplePool.Despawn() instead of Instantiate() and Destroy().  Pool sizes automatically grow to meet demand.  There is an option to preload objects if you know you’re going to need to spam out a bunch of something very quickly (for example, projectiles for a bullet-hell shmup).

WARNING: NOT YET TESTED IN A FULL PRODUCTION APPLICATION.