on-internet
← Community

Using Zenject to inject an implementation with interfaces

Stack Overflow ·

I'm trying to use Zenject in Unity. I have an interface and several implementations of it. I want to inject with ID but also that the implementation will have the tick interface since it's not a MonoBehaviour. So I have an IAttacker interface and a MeleeAttackImpl implementation. Container.Bind<IAttacker>().WithId(AttackerTypeEnum.MELEEE).To<MeleeAttackImpl>().AsTransient(); I want to add Container.BindInterfacesTo<MeleeAttackImpl>().AsTransient(); But it creates 2 different objects instead of instances that have the Tick interface and bind them to IAttacker.

Comments

Sign in or sign up to comment and upvote.

No comments yet.