/tiny-pool

A small, simple and easy to use pooling system for Unity

Primary LanguageC#

TinyPool

Using TinyPool is very easy.

Initialize:

TinyPool.Initialize();

Create a Pool:

TinyPool.CreatePool((GameObject)Prefab, 
                    (string)PoolID, 
                    (int)InitialPoolSize, 
                    (int)maxPoolSize=50, 
                    (GameObject)objectsParent);

Spawn:

GameObject spawned = TinyPool.Spawn((string)PoolID, 
                                    (Vector3)Position, 
                                    (Quaternion)Rotation, 
                                    (Vector3)Scale);

Destroy:

TinyPool.Destroy((string)PoolID, (GameObject)pooledObject);

Expand:

TinyPool.ExpandPool((string)PoolID, (GameObject)pooledObject);

Result:

Example

Installation

Just add this class to your Unity project.

Considerations

  • You have to call Initialize() just once and before any other TinyPool function.
  • You can create any number of pools at the same time, just be aware of givin them a different PoolID.

Thanks for visiting!

Feel free to use this library whatever you want whenever you want.

You can reach me at twitter @c4m170 for any questions.