Questions tagged [zenject]

Dependency Injection Framework for Unity3D

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

76 questions
1
vote
1 answer

Binding with Zenjection

I think it's better to formulate the problem via code. I have a BaseClass. public abstract class BaseUnit { [System.Serializable] public class Settings { } } And some derived classes, for example. public class Archer : BaseUnit…
Argus Kos
  • 175
  • 1
  • 12
1
vote
0 answers

Zenject pass monobehaviur object to factory

I have a Monobehaviour object BaseUnit which can have some states, so I created states factory, like in the Zenject example projects, but my question is how to pass reference of this BaseUnit when I create this factory of states for this…
Argus Kos
  • 175
  • 1
  • 12
1
vote
1 answer

Not resolved dependency in instantiated gameobject

Installer: class MainInstaller : MonoInstaller { [SerializeField] private StateController StateController; public override void InstallBindings() { Container.BindInstance( StateController ); } } Behaviour…
A. Akzhigitov
  • 179
  • 2
  • 14
1
vote
0 answers

How to fix the exception : ZenjectException: Unable to resolve type 'A' while building object with type 'B'. Object graph: B

I'm trying to load a prefab during runtime in one particular moment at my state machine. But I get this exception in runtime. All the scenes are validate with the Ctrl Left+Maj Left+V shortcut. The context of the problem My state machine is bind…
Zethzer
  • 59
  • 1
  • 7
1
vote
1 answer

Using Zenject to wire up Mapbox SDK

I'm using the Mapbox SDK and RoadArchitect and trying to build some game initialization code that uses Mapbox to generate a list of vectors, then take that list of vectors and call functions in Road Architect to generate road GameObjects. In order…
Colin Young
  • 3,018
  • 1
  • 22
  • 46
1
vote
1 answer

Inject components attached to child GameObjects of prefab

I use Factories to create GameObjects from prefabs. MenuScreen (prefab root game object) * MenuScreenComponent <- inject ScreensNavigator - Button (game object) * ButtonSoundBehaviour <- inject AssetsProvider In the…
Alexandr
  • 3,859
  • 5
  • 32
  • 56
1
vote
1 answer

Layered architecture by Zenject's DiContainers with flat GameObjectContext hierarchy

Previous question: link In my application I have three layers: Data (Entities and Data Access Objects) Model (Managers) Presentation (Views) How can I setup Game Object Context that Model layer will include all Data layer dependencies and…
Alexandr
  • 3,859
  • 5
  • 32
  • 56
1
vote
1 answer

Zenject - install generic binding

Good day. I have an interface: public interface IRepository { //Stuff } and an implementation: class Repository : IRepository { //Stuff implementation } now I would like to bind it all together in a container. I found Zenject to be…
1
vote
1 answer

How do I create factories capable of multiple parameters with Zenject?

How do I create a factories with zenject with multiple parameter overloaded Create methods (or how to solve this problem differently)? I want to be able to var x = factory.Create("bla bla");//string x = factory.Create();//parameterless x =…
Kevin Streicher
  • 484
  • 1
  • 8
  • 25
1
vote
1 answer

Injection of a field from a ScriptableObject

I have a ScriptableObjectInstaller public class Settings : ScriptableObjectInstaller { [Header("Gravity settings")] public GravityHandler.Settings GravitySettings; [Header("Movement settings")] public MovementHandler.Settings…
Chaz Ashley
  • 389
  • 1
  • 15
1
vote
1 answer

Zenject add component dynamically

How can you add a component to a gameobject? The normal path of GameObject obj = _factory.Create(); // Creates from prefab HasScore score = obj.AddComponent(); // attach the component The problem is that HasScore component is not going…
Arijoon
  • 2,184
  • 3
  • 24
  • 32
0
votes
0 answers

How to bind an interface to a MonoBehaviour in Unity3D using Zenject

I am new to Zenject and I am trying to bind an interface to a MonoBehaviour like below. In this case, I am trying to simulate to play sound inside Player. using UnityEngine; using Zenject; public class GameInstaller : MonoInstaller { public…
0
votes
0 answers

Zenject Unity3D - Injecting Dependencies from GameObject Hierarchy

I'm working on a Unity3D project using Zenject for dependency injection. In my project, i have a UpgradeCardButton component which is injected with a ButtonUpgradeCommand object. ButtonUpgradeCommand is constructed with an object of type…
0
votes
1 answer

Zenject Resolve object from Project Context with dependencies from Scene Context

I have ProjectContext with some installers for global dependencies. One of the installers: public class StateMachineInstaller : MonoInstaller { public override void InstallBindings() { BindStateFactory(); …
dest1
  • 3
  • 2
0
votes
1 answer

Zenject Binding the classes of the Factory Object by Runtime Arguments

I have a Character class. Its mono and have CharacterInstaller. And I'm using MonoPoolableMemoryPool for Character pool. But I have to bind derived class by character runtime parameters. Is there any way to do that? public enum Type { …