com.amanotes.prefabpool
v1.1.0
Published
Generic object pooling system for Unity
Downloads
244
Maintainers
Readme
PrefabPool
Package: com.amanotes.prefabpool
Version: 1.0.3
Generic object pooling system for Unity with lifecycle callbacks and material pooling support.
Features
- 🎮 Simple Get/Return API pattern
- 🎯 Automatic prefab instantiation and reuse
- 🎨 Lifecycle callbacks via IPoolPrefab interface
- 🚀 Pre-warming support for performance
- 🔧 Material pooling for dynamic instances
Documentation
Complete documentation: Docs/PrefabPool-API.md
Installation
Add the package to your Unity project via Packages/manifest.json:
{
"dependencies": {
"com.amanotes.prefabpool": "1.0.3"
},
"scopedRegistries": [
{
"name": "npmjs",
"url": "https://registry.npmjs.org/",
"scopes": [
"com.amanotes.prefabpool"
]
}
]
}Quick Start
public class PoolExample : MonoBehaviour
{
private PrefabPool pool;
private PoolGroup enemyGroup;
void Start()
{
pool = gameObject.AddComponent<PrefabPool>();
enemyGroup = new PoolGroup
{
id = "enemies",
entries = new List<PoolEntry>
{
new PoolEntry { id = "basic_enemy", prefab = enemyPrefab, prewarmCount = 10 }
}
};
pool.RegisterGroup(enemyGroup, transform);
StartCoroutine(pool.Initialize());
}
void SpawnEnemy()
{
var enemy = enemyGroup.Get<Enemy>("basic_enemy");
enemy.transform.position = GetSpawnPosition();
}
}API Reference
Key Classes
IPrefabPool
- Purpose: Core interface for pool management
- Key methods:
RegisterGroup(),Get(),Return(),Initialize()
PrefabPool
- Purpose: Main implementation of IPrefabPool
- Key methods:
RegisterGroup(),Get(),Return(),Resize<T>()
PoolGroup
- Purpose: Organizes related pool entries
- Key methods:
Get(),Get<T>(),Return()
IPoolPrefab
- Purpose: Lifecycle callbacks for pooled objects
- Key methods:
OnGet(),OnReturn()
Dependencies
- Unity 2022.3+
Version History
See CHANGELOG.md
