Skip to content

merpheus-dev/PoolUtility

Repository files navigation

Pool Utility

Pooling Utility is a simple and powerful pooling system for Unity. It is generic, so any object that implements base classes can be pooled easily.

Usage

  1. Inherit your monobehaviour object from PoolableObject class.
public class MyAwesomeEnemy:PoolableObject
{
    //Logic
}
  1. Inherit a data container from SpawnDataContainer for injecting data to your Monobehaviour class.
public class EnemySpawnData:SpawnDataContainer
{
    public Vector3 SpawnPosition;
}
  1. Use PoolManager to pool your object.
[SerializeField] private MyAwesomeEnemy prefab;

private void Start()
{
    PoolManager.GetInstance().GenerateNewPool(prefab);
}

Then you can spawn/despawn your prefab clones from the pool as follows:

//Request spawn
var spawnedObject = PoolManager.RequestSpawnForType(prefab,dataContainer);

//Request despawn
PoolManager.DespawnObject(prefab, spawnedObject);

About

Simple Pooling System for Unity

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages