Factories of Sub-Containers using GameObjectContext from non MonoBehaviour class

I have factory which spawns Sub-Container using MonoBehaviour based Player but this leads to errors with initialization order, and null refs from other (non MonoBehaviour) classes using that Player when their Initialize() happen. I don't know how to spawn such thing without class inherited from MonoBehaviour because Zenject expects that such MonoBehaviour is placed inside ZenjectBinding component so can be Injected later. I still want to bind new things inside that newly created Sub-Container so GameObjectContext is probably way to go.

Making it short https://github.com/modesttree/Zenject/blob/master/Documentation/SubContainers.md#hello-world-for-facades -> Creating Sub-Containers on GameObject's by using Game Object Context

Is it possible to replace example from above documentation:

public class Ship : MonoBehaviour

... to this? (for example)

public class Ship : IInitializable, IShip

Edit: My issue is similar to that one but I still can't grasp it https://groups.google.com/forum/#!searchin/zenject/GameObjectContext|sort:date/zenject/xELHG41TNcg/urFOepsECgAJ

I made workaround by delaying Initialize by using

Container.BindExecutionOrder<Foo>(x); vs default 0

If someone is interested I posted that question also on google group of Zenject https://groups.google.com/forum/#!topic/zenject/mwKDDZNtYpw

Posted Feb 15, 2018, 9:12 AM UTC · edited

10
Loading comments…