ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.53k stars 363 forks source link

Initializing a Subcontainer using PrefabFactory #594

Open pajama opened 5 years ago

pajama commented 5 years ago

I see that I can initialize a subcontainer from a new prefab using: Container.BindFactory<Object, Param, ThingToCreate, ThingToCreate.Factory>().FromSubContainerResolve().ByNewContextPrefab<Installer>(SubContainerPrefab)

But what If I want to use a prefab factory, instead of specifying an explicit prefab to use?

svermeulen commented 5 years ago

Yep you're right there isn't really an easy way to do this currently

svermeulen commented 5 years ago

Normally I'd suggest using a custom factory but this specific case is tricky, because you want to pass the arguments to the given Installer type, so you have to reproduce some of the logic inside SubContainerCreatorByNewPrefabWithParams.cs for that.

pajama commented 5 years ago

@svermeulen thanks for pointing me to that class. I'll try digging a little deeper.

pajama commented 5 years ago

@svermeulen I think I'm a little in over my head. Is there any more info you can provide on how to set this up?