Add in Packages/manifest.json
to dependencies
:
"com.danand.genericpool": "https://github.com/Danand/GenericPool.git#0.1.1-package-unity"
Replace all:
Object.Instantiate(prefab)
withPoolUnity.Get(prefab)
Object.Destroy(instance)
withPoolUnity.Put(instance)
Notice that PoolUnity
actually is not a static class. It must be properly injected instance, in the way you liked (DI or just GetComponent<PoolUnity>()
).
It's possible to get instance, use and return to pool with delay:
PoolUnity.GetWith(audioPrefab)
.Then(audio => audio.Play())
.ThenWait(audio => TimeSpan.FromSeconds(audio.clip.length))
.ThenPut()