Unity Simple ObjectPool is a lightweight object pooling system for Unity, designed to efficiently manage and reuse GameObjects in your projects.
- Efficient object pooling: Reuse GameObjects instead of instantiating and destroying them repeatedly.
- Easy integration: Simply attach the provided ObjectPool script to your GameObject prefabs to start pooling.
- Adjustable pool size: Set initial pool size and minimum amount to enlarge the pool as needed.
- Events support: Subscribe to events for object creation, retrieval, and return.
- Clone or download the repository.
- Import the ObjectPool.cs script into your Unity project.
- Initiate the ObjectPool.
- Configure initial pool size and other parameters as needed.
- Attach the ObjectPool script to your GameObject prefabs that you want to pool.
- Configure initial pool size and other parameters through the Unity Inspector.
- Use the
Get()
method to retrieve objects from the pool. - Use the
Return()
method to return objects to the pool when no longer needed.
// Instantiate an object pool
ObjectPool objectPool = new ObjectPool(prefab, initialPoolSize);
// Retrieve an object from the pool
GameObject obj = objectPool.Get();
// Do something with the object
// Return the object to the pool
objectPool.Return(obj);
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit issues or pull requests.