Skip to content

ertanturan/Unity-Object-Pooling

Repository files navigation

Runtime-extendible Object-pooler within unity

This pool creates objects that you defined on start and creates additionally if more spawn request comes to the pool than pools capacity and manages newly added pool objects too ! .

Pre-requisities

  • Zenject IOC (Find HERE )

Import

  1. Go to release page.
  2. Download the lates release of the package.
  3. Import it to your unity project.

Usage

  1. Head to your hierarchy >> Right Click >> Create Empty
  2. Add Component >> Object Pooler >> Set size that you wish to add to your project.
  3. Create Script which inherits from IPooledObject interface

public Class ExampleClass : MonoBehaviour,IPooledObject

  1. Add a new type to enum PooledObjectType (Can be found under Assets/Scripts/ObjectPool/PooledObjectType.cs)
  2. Retrun to the game object you created on hierarchy drag and drop your prefab to Prefab property on objectpooler's pool . Set the tag you wrote on step 4. set size (How many object you want to create on beginning).
  3. Ready to go !

To Spawn and Despawn

Spawn

ObjectPooler.Instance.SpawnFromPool(PooledObjectType.YourTypeComesHere , transform.position, Random.rotation);

Despawn

ObjectPooler.Instance.Despawn(gameObject);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Acknowledgement/Courtesy

This project uses Zenject framework for Dependency Injection. Courtesy to Modesttree. REFERENCE LINK

ENJOY !

About

Runtime-Extendible Object Pooler for unity .

Topics

Resources

License

Stars

21 stars

Watchers

2 watching

Forks

Packages

 
 
 

Contributors

Languages