我正在尝试在 Unity 中使用 Zenject。我有一个接口和它的几个实现。
我想用 ID 注入,但实现将具有刻度接口,因为它不是 MonoBehaviour。
所以我有一个IAttacker
接口和一个MeleeAttackImpl
实现。
Container.Bind<IAttacker>().WithId(AttackerTypeEnum.MELEEE).To<MeleeAttackImpl>().AsTransient();
我想添加
Container.BindInterfacesTo<MeleeAttackImpl>().AsTransient();
但它创建了 2 个不同的对象,而不是具有 Tick 接口并将它们绑定到IAttacker
.