private static T CreateInternal <T>(Type type, Transform parent) where T : InjectedMonoBehaviour { var typeRef = new TypeReferenceContainer { type = type }; var injectedMonoBehaviour = Instantiate(_instance._injectedPrototypes[typeRef], parent); if (!_behaviours[type].Contains(injectedMonoBehaviour)) { _behaviours[type].Add(injectedMonoBehaviour); } return((T)injectedMonoBehaviour); }
public Container MakeDependency <T>(bool useExisting, out T dependency, Transform parent = null) where T : InjectedMonoBehaviour { var type = typeof(T); var typeRef = new TypeReferenceContainer { type = type }; if (!_instance._injectedPrototypes.ContainsKey(typeRef)) { throw new KeyNotFoundException($"No prototype of type {type} in Injected prototypes dict"); } dependency = useExisting ? GetOrCreate <T>(parent) : CreateAndGet <T>(parent); return(_instance); }