[ad_1]
I wish to begin utilizing zenject in my undertaking however I encountered a difficulty.
From their tutorial in github web page I used to be in a position to inject non monobehavior objects into one another like this.
public class MyInstaller : MonoInstaller {
public override void Set upBindings() {
Container.Bind<string>().FromOccasion("Hello World!");
Container.Bind<Greeter>().AsSingle().NonLazy();
Container.Bind<BasicArmorDamageCalculator>().AsSingle().NonLazy();
}
}
public class Greeter {
public Greeter(String message) {
Debug.Log("this was injected: " + message);
}
}
But the issue is that I can’t inject objects to Monobehavior lessons.
Using this Installer I attempted to inject Greeter to monobehavior class like this
[Zenject.Inject]
public void Construct(Greeter greeter) {
Debug.log(greeter);
}
And the greeter variable is null. As I perceive I’ve to register my monobehavior class within the Installer class however It requires instantiating it whereas mono class is already on some sport object.
What is the answer to this one?
Thanks upfront!
[ad_2]