public DiContainer CreateSubContainer( List <TypeValuePair> args, InjectContext parentContext) { var prefab = _prefabProvider.GetPrefab(); bool shouldMakeActive; var gameObj = _container.CreateAndParentPrefab( prefab, _gameObjectBindInfo, null, out shouldMakeActive); if (gameObj.GetComponent <GameObjectContext>() != null) { throw Assert.CreateException( "Found GameObjectContext already attached to prefab with name '{0}'! When using ByNewPrefabMethod, the GameObjectContext is added to the prefab dynamically", prefab.name); } var context = gameObj.AddComponent <GameObjectContext>(); AddInstallers(args, context); _container.Inject(context); if (shouldMakeActive) { gameObj.SetActive(true); } // Note: We don't need to call ValidateValidatables here because GameObjectContext does this for us return(context.Container); }
protected override GameObject CreateGameObject(InjectContext context, out bool shouldMakeActive) { var prefab = _prefabProvider.GetPrefab(context); var gameObj = Container.CreateAndParentPrefab( prefab, _gameObjectBindInfo, null, out shouldMakeActive); if (gameObj.GetComponent <GameObjectContext>() != null) { throw Assert.CreateException( "Found GameObjectContext already attached to prefab with name '{0}'! When using ByNewPrefabMethod or ByNewPrefabInstaller, the GameObjectContext is added to the prefab dynamically", prefab.name); } return(gameObj); }
public DiContainer CreateSubContainer(List <TypeValuePair> args) { Assert.That(!args.IsEmpty()); var prefab = _prefabProvider.GetPrefab(); var gameObject = CreateTempContainer(args).InstantiatePrefab( prefab, new object[0], _gameObjectBindInfo); var context = gameObject.GetComponent <GameObjectContext>(); Assert.IsNotNull(context, "Expected prefab with name '{0}' to container a component of type 'GameObjectContext'", prefab.name); return(context.Container); }
public DiContainer CreateSubContainer(List <TypeValuePair> args, InjectContext parentContext) { Assert.That(args.IsEmpty()); var prefab = _prefabProvider.GetPrefab(); var gameObject = _container.InstantiatePrefab(prefab, _gameObjectBindInfo); var context = gameObject.GetComponent <GameObjectContext>(); Assert.That(context != null, "Expected prefab with name '{0}' to container a component of type 'GameObjectContext'", prefab.name); // Note: We don't need to call ValidateValidatables here because GameObjectContext does this for us return(context.Container); }
public DiContainer CreateSubContainer(List <TypeValuePair> args, InjectContext parentContext) { Assert.That(!args.IsEmpty()); UnityEngine.Object prefab = _prefabProvider.GetPrefab(); UnityEngine.GameObject gameObject = CreateTempContainer(args).InstantiatePrefab(prefab, _gameObjectBindInfo); GameObjectContext context = gameObject.GetComponent <GameObjectContext>(); Assert.That(context != null, "Expected prefab with name '{0}' to container a component of type 'GameObjectContext'", prefab.name); // Note: We don't need to call ResolveRoots here because GameObjectContext does this for us return(context.Container); }
public DiContainer CreateSubContainer(List <TypeValuePair> args, InjectContext parentContext, out Action injectAction) { Assert.That(!args.IsEmpty()); var prefab = _prefabProvider.GetPrefab(parentContext); var tempContainer = CreateTempContainer(args); bool shouldMakeActive; var gameObject = tempContainer.CreateAndParentPrefab( prefab, _gameObjectBindInfo, null, out shouldMakeActive); var context = gameObject.GetComponent <GameObjectContext>(); Assert.That(context != null, "Expected prefab with name '{0}' to container a component of type 'GameObjectContext'", prefab.name); context.Install(tempContainer); injectAction = () => { // Note: We don't need to call ResolveRoots here because GameObjectContext does this for us tempContainer.Inject(context); if (shouldMakeActive && !_container.IsValidating) { #if UNIDI_INTERNAL_PROFILING using (ProfileTimers.CreateTimedBlock("User Code")) #endif { gameObject.SetActive(true); } } }; return(context.Container); }
public UnityEngine.Object GetPrefab() { return(_prefabProvider.GetPrefab()); }
public UnityEngine.Object GetPrefab(InjectContext context) { return(_prefabProvider.GetPrefab(context)); }
public GameObject GetPrefab() { return(_prefabProvider.GetPrefab()); }