2075 / Unity / 2D / 3D / Шаблони / Extenject Dependency Injection IOC
Extenject Dependency Injection IOC – Застарів
Zenject – ok, hithub
Vcontainer – ok
OneShoot – для простих завдань
Впроваджує посилання в ігрові об'єкти (на інші ігрові об'єкти) при старті


1. using System.Collections; using System.Collections.Generic; using UnityEngine; using Zenject; public class GameplaySceneInstaller : MonoInstaller { public override void InstallBindings() { Container.Bind<IInput>().To<DesctopInput>().FromNew().AsSingle(); Container.Bind<MovementHendler>().FromNew().AsSingle().NonLazy(); } } 2. public interface IInput { } 3. public class DesctopInput : IInput { } 4. using UnityEngine; public class MovementHendler { private IInput input; public MovementHendler(IInput input) { this.input = input; Debug.Log(input.GetType()); } }

