RefPool is a lightweight, ScriptableObject-driven pooling system for Unity 6.0 and above.
It enables clean, efficient reuse of GameObjects across scenes without relying on global registries.
- ScriptableObject-based pool references for cross-scene linking
- Lazy pool initialization and automatic cleanup on unload
- Efficient memory management through shared pooling
- Supports runtime spawning with configurable options such as spawn rate, position overrides, and randomization
- Clean integration with Unity’s component model
- Extendable through custom
PoolResource
implementations for advanced pooling behaviors
- Open your Unity project
- Go to
Packages/manifest.json
- Add the following line to the
dependencies
block:
"com.bluepixeldev.refpool": "https://github.com/bluepixeldev/refpool.git"
Clone or download this repository and move the RefPool
folder into your project's Assets
directory.
- Right-click in the
Project
window - Select
Create > RefPool > Pool or Pool Group
- Assign the prefab and configure pool size, increment size, and other settings
- Attach the
RefPoolSpawner
component to a GameObject - Assign the
PoolResource
you created - Configure spawn behavior as needed
You can trigger pooled object spawning manually or automatically:
[SerializeField] private PoolSpawner spawner;
void SomeEventTrigger()
{
spawner.Spawn();
}
RefPool allows you to implement custom pooling logic by extending the PoolResource
class. This enables advanced use cases such as dynamic pool resizing, custom initialization, or specialized cleanup logic.
Here’s an example of a custom PoolResource
:
using UnityEngine;
namespace BP.RefPool
{
public class CustomPoolResource : PoolResource
{
public override void Initialize()
{
// Custom initialization logic
}
public override GameObject Get()
{
// Custom logic for retrieving a GameObject from the pool
return null;
}
public override bool Release(GameObject gameObject)
{
// Custom logic for releasing a GameObject back to the pool
return true;
}
}
}
This flexibility allows you to tailor the pooling system to your specific project requirements.
Pull requests and issues are welcome. If you encounter a bug or have a feature suggestion, please open an issue on GitHub.