/pools

A typesafe, lightweight pooling lib for Unity.

Primary LanguageC#MIT LicenseMIT

Pools

A typesafe, lightweight pooling lib for Unity.


Inspired by Signals by Yanko Oliveira.

You can find the repository of Signals by Yanko Oliveira here.

Uses the ObjectPool of UnityEngine.

Author: matt-mert

Usage:

  1. Define your pool, eg:
public class SomePool : APool<SomeObject> {}
  1. Initialize your pools, eg on Awake():
Pools.Get<SomePool>().Initialize(SomePrefab);
  1. Grab objects from the pool, eg:
var obj = Pools.Get<SomePool>().Grab();
  1. Release objects to the pool, eg:
Pools.Get<SomePool>().Release(obj);
  1. You also have your local Pool Hub that is specific to a given object instead of using the global one. The syntax is exactly the same.
PoolHub environmentPools = new PoolHub();
var wall = environmentPools.Get<WallPool>().Grab();