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 ! .
- Zenject IOC (Find HERE )
- Go to release page.
- Download the lates release of the package.
- Import it to your unity project.
- Head to your
hierarchy >> Right Click >> Create Empty - Add Component >> Object Pooler >> Set size that you wish to add to your project.
- Create Script which inherits from IPooledObject interface
public Class ExampleClass : MonoBehaviour,IPooledObject
- Add a new type to
enum PooledObjectType(Can be found underAssets/Scripts/ObjectPool/PooledObjectType.cs) - 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).
- Ready to go !
ObjectPooler.Instance.SpawnFromPool(PooledObjectType.YourTypeComesHere , transform.position, Random.rotation);
ObjectPooler.Instance.Despawn(gameObject);
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.
This project uses Zenject framework for Dependency Injection. Courtesy to Modesttree. REFERENCE LINK