Questions tagged [zenject]

Dependency Injection Framework for Unity3D

For further details, see https://github.com/modesttree/Zenject

76 questions
5
votes
1 answer

Zenject GameObject Injection

I'm using Zenject framework and I'm using multiple GameObject for a class but I don't know to do it using Zenject Container. Here's my code: private GameObject _canvas; private GameObject _mainWindow; private GameObject _createAccountWindow; void…
4
votes
0 answers

Trying to run multiple Zenject installers on a Zenject subcontainer, where the installers are in separate asmdef modules

My Unity project is split into a Core project and several Modules, in different asmdef assembly definitions. Each module has an assembly reference to Core. My Core installer looks like: public class CoreInstaller : MonoInstaller { …
Chazmus
  • 91
  • 5
4
votes
1 answer

Can you have generic create method for Zenject

So I have a base class and some derived classes, I want to have just one factory with generic create method witch will create appropriate instances and inject all dependencies. Is this possible using Zenject? Something…
Argus Kos
  • 175
  • 1
  • 12
3
votes
1 answer

Use Zenject FromSubContainerResolve on ProjectContext to SceneContext

I have a Unity + Zenject setup with a ProjectInstaller with some global dependencies that adhere to a "modal" interface, e.g., public class ProjectInstaller : MonoInstaller { public override void InstallBindings() { …
Charlie
  • 15,069
  • 3
  • 64
  • 70
2
votes
0 answers

Syncing Zenject and StateMachine after scene division and loading it from Photon Fusion -Unity

I'm facing a critical issue with syncing Zenject and StateMachine after dividing my game into multiple scenes. Previously, the game ran in a single scene with GRPC networking, but due to changes, I've removed GRPC and split the game into four…
Humza Butt
  • 44
  • 2
2
votes
2 answers

Zenject: MonoBehaviour injection

I'm new to Zenject and this is my first project using this asset. I'm having injection problems! Maybe someone knows what I am doing wrong or where the error might be. In the code below, _spawnArea is not initialized. public class BootstrapIniter :…
2
votes
1 answer

Unity & Zenject - How to execute methods in sequence order from a TSignal.Fire()

I am trying to learn how to work with Zenject's and unity and I have encountered a particular problem that I do not know if it has a possible solution solely using Zenject's api. Let assume i have MethodA, MethodB and MethodC, and a SignalA. Is it…
2
votes
1 answer

Using Zenject to inject an implementation with interfaces

I'm trying to use Zenject in Unity. I have an interface and several implementations of it. I want to inject with ID but also that the implementation will have the tick interface since it's not a MonoBehaviour. So I have an IAttacker interface and a…
Itamar Kerbel
  • 2,508
  • 1
  • 22
  • 29
2
votes
0 answers

How can I best automate ScriptableObject injection with Zenject?

I want users to be able to create my ScriptableObject assets outside of play mode so they can bind them to their objects in the scene. Since I don't want Zenject creating the ScriptableObjects, a Factory solution is not what I'm looking for.…
2
votes
2 answers

Zenject Mono Installer not called in Scene tests under some circumstances

I have a "Main" scene consisting of a softozor game object which is controlled by the player. It's a flappy dinosaur. As a child of that softozor game object, I have setup another game object, Installer, consisting of a Transform component and a…
Laurent Michel
  • 1,069
  • 3
  • 14
  • 29
2
votes
0 answers

What's Wrong with my DI? - Dependency Injection, Unity - Null Reference Only After Injection

I'm new to Dependency Injection and I have been doing my research for a few days now but can't seem to find answers; there is not a whole lot of examples out there specific to zenject so I have been looking into both specific zenject solutions as…
2
votes
0 answers

How to use zenject outside and inside Unity, but with different DiContainers?

I am developing a platform for a videogame, it is pure c # code and I want to use Zenject for dependency injection. The idea is that this platform can initialize its dependency injection regardless of where it is being used. I have this class on the…
Jasiel
  • 121
  • 5
2
votes
1 answer

How to register a GameObject with Zenject's IOC container

The Zenject documentation shows adding a component to a GameObject looking like: However mine looks like: How come mine appears to add a Collection of GameObjects rather than a single GameObject? I also show an Identifier whereas the example…
Ben
  • 60,438
  • 111
  • 314
  • 488
1
vote
0 answers

Zenject: Injection creating different SignalBus, with solution and oddities

This is for Zenject being used with Unity. I have a Project Context that holds a monoinstaller which should make bindings and the signalbus global, which works 99% of the time. I have a Loading Scene and a Main Scene. In the Loading Scene I have a…
FrontBadger
  • 41
  • 1
  • 4
1
vote
1 answer

Zenject: FromMethod and OnInstantiated

using this kind of contstruction: Container.Bind() .FromMethod(_ => { return Container.InstantiatePrefabForComponent(freemanPrefab); }) .AsTransient() .OnInstantiated((injCtx, freeman) => { …
vladroot
  • 11
  • 2
1
2 3 4 5 6