private GameObject InjectDependencies([NotNull] GameObject obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } InjectionStrategy.InjectDependencies <MonoBehaviour>(InjecteeLocator <MonoBehaviour> .Create(obj), ResolverService); return(obj); }
private void InjectDependencies() { InjecteeLocator <MonoBehaviour> behaviours = new InjecteeLocator <MonoBehaviour>(); AutoFacToIResolverAdapter resolverAdapter = new AutoFacToIResolverAdapter(BuiltContainerResolver); foreach (MonoBehaviour b in behaviours) { Injector injector = new Injector(b, resolverAdapter); injector.Inject(); } }
public GameObject Create([NotNull] GameObject prefab, Vector3 position, Quaternion rotation) { if (prefab == null) { throw new ArgumentNullException(nameof(prefab)); } GameObject obj = GameObject.Instantiate(prefab, position, rotation) as GameObject; //Decorate the current resolver with one that uses the contextual services IResolver resolver = new ContextualDependencyResolverDecorator(ResolverService, ServiceMap); //Inject using the decorated resolver InjectionStrategy.InjectDependencies <MonoBehaviour>(InjecteeLocator <MonoBehaviour> .Create(obj), resolver); return(obj); }