public DiContainer CreateSubContainer( List <TypeValuePair> args, InjectContext parentContext) { UnityEngine.Object prefab = _prefabProvider.GetPrefab(); bool shouldMakeActive; UnityEngine.GameObject 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); } GameObjectContext context = gameObj.AddComponent <GameObjectContext>(); AddInstallers(args, context); _container.Inject(context); if (shouldMakeActive) { gameObj.SetActive(true); } // Note: We don't need to call ResolveRoots here because GameObjectContext does this for us return(context.Container); }
protected override void AddInstallers(List <TypeValuePair> args, GameObjectContext context) { context.AddNormalInstaller( new ActionInstaller((subContainer) => { var installer = (InstallerBase)subContainer.InstantiateExplicit( _installerType, args.Concat(_extraArgs).ToList()); installer.InstallBindings(); })); }
public DiContainer CreateSubContainer(List <TypeValuePair> args, InjectContext parentContext) { Assert.That(args.IsEmpty()); UnityEngine.Object prefab = _prefabProvider.GetPrefab(); UnityEngine.GameObject gameObject = _container.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); }
protected override void AddInstallers(List <TypeValuePair> args, GameObjectContext context) { context.AddNormalInstaller( new ActionInstaller(subContainer => { var extraArgs = ZenPools.SpawnList <TypeValuePair>(); extraArgs.AllocFreeAddRange(_extraArgs); extraArgs.AllocFreeAddRange(args); var installer = (InstallerBase)subContainer.InstantiateExplicit( _installerType, extraArgs); ZenPools.DespawnList(extraArgs); installer.InstallBindings(); })); }
protected abstract void AddInstallers(List <TypeValuePair> args, GameObjectContext context);
protected override void AddInstallers(List <TypeValuePair> args, GameObjectContext context) { Assert.That(args.IsEmpty()); context.AddNormalInstaller( new ActionInstaller(_installerMethod)); }