Quick Pool

by densylkin
+

Simple pooling toolkit for Unity game engine

( Updated an hour ago )

Unity-QuickPool

Asset store

Usage

You can use quickpool in two ways:

  • Create PoolManager and configure your pools with editor

Imgur

  • Or create a Pool field (in this case you will need to register your pool somewhere in Start with PoolManager.RegisterPool())

Imgur

Include QuickPool namespace

using QuickPool;

You can use extention methods

var instance = somePrefab.Spawn(Vector3.zero, Quaternion.identity);
var component = somePrefab.Spawn<Component>(Vector3.zero, Quaternion.identity);
obj.Despawn();

You also can get concrete pool from PoolManager or use that one you have created

public Pool pool = new Pool()
{
  size = 100,
  allowGrowth = true
};

// OR

var pool = PoolManager.Instance["pool name"];
private void Start()
{
  PoolsManager.RegisterPool(pool); //register pool if you want to use extention method Despawn
  pool.Initialize(); 

  var instance = pool.Spawn(Vector3.zero, Quaternion.identity);
  var conponent = pool.Spawn<Component>(Vector3.zero, Quaternion.identity);
  pool.Despawn(instance);
}

Despawn all spawned objects

PoolsManager.DespawnAll();
// OR
pool.DespawnAll();