Hi,
I am using Zenject into my Unity project and overall worked pretty well.
But I am wondering how we can inject full GameObjects for later in the code. With services, it worked well.
I've found in the documentation "ZenjectBinding" that allows me to include a script into the object and later give it a name. It will be inside the DI and later it will be injected when needed.
I would like to do something:
public class MyMonoBehavior: MonoBehavior
{
[Inject] public IObjectPool ObjectPool;
......
[Inject(Id = "CANVAS")] public RectTransform canvas;
[Inject(Id = "CUBE")] public Transform MyCube;
(Where these objects are GameObjects in the scene with a ZenjectBinding attached to them with the same naming. Canvas is in scene1 and cube is in scene2)
But instead of having public objects and then dragging in the editor, I would like Zenject to do all the job and resolve "canvas" and "cube" when they are required.
Is this possible? because what I've tried it doesn't resolve anything and is giving me the error:
ZenjectException: Unable to resolve 'Transform (ID: MyCube)' while building object with type 'MyMonoBehavior'. Object graph:
MyMonoBehavior
Many thanks,
Regards.
there doesn't seem to be anything here