You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now it's a lot of setup to just spawn a prefab.
The class looks like this:
publicclassBefore:MonoBehaviour,IPoolable<IMemoryPool>,IDisposable{privateIMemoryPool_pool;publicvoidOnDespawned(){_pool=null;}publicvoidOnSpawned(IMemoryPoolp1){_pool=p1;}publicvoidDispose(){_pool.Despawn(this);}publicclassFactory:PlaceholderFactory<Before>{}publicclassPool:MonoPoolableMemoryPool<IMemoryPool,Before>{}}publicclassAfterInstaller:MonoInstaller{publicAfterprefab;publicoverridevoidInstallBindings(){Extensions.BindPoolable<After>(Container,
c =>c.WithInitialSize(5).FromComponentInNewPrefab(prefab).UnderTransformGroup("After").AsCached());}}publicclassAfter:PoolableMonoBehaviour<After>{}
With these new scripts, the code goes from looking like it did at the top to this:
publicclassAfterInstaller:MonoInstaller{publicAfterprefab;publicoverridevoidInstallBindings(){Extensions.BindPoolable<After>(Container,
c =>c.WithInitialSize(5).FromComponentInNewPrefab(prefab).UnderTransformGroup("After").AsCached());}}publicclassAfter:PoolableMonoBehaviour<After>{}
This makes it mech easier to for a gameobject to return itself to the pool
This isn't really an issue, just now that Extenject isn't being supported I thought it would be useful for people trying to wrap their heads around prefab spawning.
The text was updated successfully, but these errors were encountered:
Right now it's a lot of setup to just spawn a prefab.
The class looks like this:
and the binding looks like this
I wrote a wrapper class for this kind of thing.
Right now it doesn't support parameters, but that would be easy to do, just duplicate the class and add TParam infront of Every IMermoryPool.
I also wrote an extension method for binding
With these new scripts, the code goes from looking like it did at the top to this:
This makes it mech easier to for a gameobject to return itself to the pool
This isn't really an issue, just now that Extenject isn't being supported I thought it would be useful for people trying to wrap their heads around prefab spawning.
The text was updated successfully, but these errors were encountered: