Presents

  • Pool Instances with spawn/despawn instead of instantiate/destroy, bypassing time-expensive garbage collection and avoiding frame-rate stutters!
    • Pool "Pre-Runtime" Instances. Objects you place in a scene before playing the game can be managed by a pool too!
  • No Complex Set Up Required, just drop a PoolManager SpawnPool component on a game object and switch your code from Instantiate() to Spawn() and Destroy() to Despawn(). The arguments are the nearly the same but PoolManager offers more options!
  • Initializes and cleans-up automatically to work well will level loading. Includes an option to 'DontDestroyOnLoad" in case you need pools persistent. (See the Unity docs for details of this behavior.)
  • Many Prefabs, One Logical Pool. A pool may contain instances from more than one prefab. This allows for a more user-friendly and logical grouping, such as pools for all enemies, explosions, projectiles, or anything else you want! You define the names and there is virtually no overhead difference between using 1 pool or 20 pools, so go ahead and work the way that is logical to you!
  • Define "Advanced" Per-Prefab Options (Optional). Use Unity's Inspector with prefab drag & drop to define pools with more options, or do the same through scripting! This is optional so to get started fast you don't have to use these options.
    • Pre-Load Instances to avoid reference loading and frame-rate stutters during game play; pre-load as many or as few as you want! This is incredibly important as it causes Unity to load as much information as possible before game-play begins.
    • "Smart" Instance Culling to destroy de-spawned (inactive) instances if the size of the pool grows too large. This is great for controlling memory clean-up after extreme game events. If used, this feature is passive until a set of circumstances triggers a timer to delay clean-up. Culling will then turn itself off when the target number is reached. Fine-tune parameters to control when and how often culling occurs!
    • Limit the number of instances allowed in the game at one time. This can be handy for small non-essential items, such as small bullets or minor flares!
  • Automatically Organizes Your Scene and appends a padded number to instances to make development and debugging your game easier!

    • SpawnPools can be added or removed from a scene anytime and PoolManager will automatically initialize and clean-up the pools.

    • Make pools prefabs for easy loading at any time, even load them with a game level!

    • SpawnPools can be parented anywhere in your scene to make spawns follow objects, such as a camera for GUI elements like in-game progress bars.
  • Internally Caches everything so when you receive a reference from Spawn(), there is no overhead. Compare this to what Unity does when you use Instantiate)... creates a new instance in memory which you then have to cast to a GameObject type, and if you want a Transform, you have to use GameObject.transform, which is an extra GetComponent() call.
  • Debug Option to log messages so you know exactly what is happening with your pools! Debugging takes a hierarchical approach, so you can debug only instances coming from a specific prefab, or the entire SpawnPool.
  • Pool Unity's UI Elements! Or any sprite-based UI system elements.
  • Pool Audio! When an AudioSource reference is used to Spawn an instance, the audio will play and then auto-despawn.
  • Pool ParticleSystems! When a ParticleSystem reference is used to Spawn an instance, the particles will play and then auto-despawn. Auto-despawn is a feature that Unity doesn't offer.
  • Each pool is also a list which contains ONLY the spawned (active) instances. This is a handy utility that gives you easy static access to work with your instances.
  • Want to manage Instantiate and Destroy yourself to add functionality or use an alternate instancer, such as a network manager? Use the global or per-SpawnPool override delegates!
  • Having trouble with Awake() races? PoolManager offers an OnCreated delegate for C# users which will run your code after the pool is created, solving this common and frustrating issue!
  • And much more, such as a method to get the prefab used to create an instance, something Unity doesn't offer, and a custom Editor to help you stay organized and work faster! 

PoolManager allows you to easily create as many instance pools as you wish and then access them during run-time without the need to explicitly store references to scripts. We spent a lot of time thinking about ways to avoid intense tasks during game-play so you don't have to.

What we didn't expect is that we would find ourselves using PoolManager on objects which don't need pooling just to use the organizational features! Preloading, automatic scene hierarchy organization, debugging messages and static access to lists of objects in the scene are all valuable on their own.

PoolManager has grown in to a full-featured yet still easy to use solution. All of the features shown above are either automatic or easy to access, and you will find complete documentation and active support on our forums, email or even Skype in some situations.

All components are namespaced to protect your project from Type collisions.

Why Use Pooling?

When instances of a Prefab are needed over and over, it is more efficient to only create one, and instead of destroying it, reuse it. This is referred to as 'instance pooling'; where you take an item from the pool first, and only create new instances if none are available. Most importantly, Destroy() has been reported to be the worst part of the instance/destroy paradigm, causing garbage collection stutters (momentary freezing every few seconds). Pooling removes the Destroy() entirely.

In some extreme cases, you may still want to destroy objects for memory management. PoolManager offers features to make culling of pool items easy. Just set a few parameters in Unity's Inspector and you are done. Need to wipe out a whole pool? Simply delete a SpawnPool from the scene and PoolManager will clean everything up!


Getting Started Couldn't Be Simpler


Simply create a SpawnPool by adding a component to your scene and enter the name you want to use (in this example, "Enemies"). Then, in a script, you can...

// Use Spawn() instead of Unity's Instantiate()
Transform enemy = PoolManager.Pools["Enemies"].Spawn(myEnemyPrefab)

// Use Despawn() instead of Unity's Destroy() to de-spawn an enemy for reuse
PoolManager.Pools["Enemies"].Despawn(enemy);

You can continue to use Awake() to initialize references and do time-expensive one-time tasks, but two events are made optionally available to manage the behaviour of instances as they spawn and de-spawn: "OnSpawned()" and "OnDespawned()"


Custom Inspector Interface   (New in version 2.5)

PoolManager comes with a custom Inspector interface to streamline the workflow


See the Quick-Start Guide, Code Reference and sample files for more Information!