Easy Objects Pool


Do you need to spawn a lot of objects and don’t want to lose performance for expensive instanti- ate/destroy functions? This system is a perfect decision!

It is incredible easy to use and doesn’t require any additional coding.
Moreover, clear and well documented source code (with no DLLs) will allow you to im- prove/adapt it easily, if needed.

The system allows:

  • Create and maintain a pool of preloaded objects
  • Spawn/de-spawn them without performance loss
  • Access pools either by name or ID
  • You can add any object to pool (even wasn’t pooled before)

This system works on all platforms supported by Unity3D. 

How to use

To use this system – you should just:

  1. Add PoolManager script to any object and specify list (and quantity) of objects you’d like to preload.

  2. If needed - for this list assign prefabs of objects to preload(generate objects on Start)

  3. It’s ready!

    You can extract preloaded or manually pooled objects using functions:

    GetObjectByName (objectName: String)
    GetObjectByID (id: int)
    You can pool any objects manually by function:
    PoolObject (object: GameObject, PreloadedTypeOnly: boolean)


  4. ADDITIONAL: Assign pooledObject script to any object (and set any existing PoolManager to parentPool property) to make this object pool-back to parentPool automatically onDIsable event. 


PoolManager description

This is the main script to handle objects pool.
Script allows to create pool of pre-seted objects (in needed quantity) and handle their extraction or pooling back

If needed. You can add any object to pool. It’s better to use PooledObject script with objects to add.

Average structure looks like: 

  • PreloadObjects - List of objects that should be preloaded to the pool Each element of this list has next properties to setup:
  1. customName - Specify custom name if you want all instances to be renamed
  2. objectPrefab - Prefab to instantiate and pool
  3. quantity - Quantity of instances
  4. addAutoPoolScript - Add script to pool object back automatically. I.e. objects with this
  • script will be pooled back to pool onDIsable automatically.
  • Pool – Internal array of all stored objects 

PooledObject script description

Service script for pooled objects or objects to pool.
Script allow to pool objects to custom (or parent) pool manualy or onDisable.

Average structure looks like: 

  • parentPool - Link to PoolManager to add object
  • poolOnDisable - Set true if you want to pool object automatically on Disable even