I'm getting a ZenjectException: Unable to resolve 'Facade'. Object graph:
error that I can't understand.
I've been following this example but I can't get my code to work.
I have a prefab with the following components:
Facade
FacadeInstaller
Game Object Context
(that references theFacadeInstaller
above)
The Facade
class:
using UnityEngine;
using Zenject;
public class Facade : MonoBehaviour
{
public class Factory : PlaceholderFactory<Argument, Facade> { }
}
The FacadeInstaller
class:
public class FacadeInstaller : MonoInstaller
{
[Inject]
Argument arg;
public override void InstallBindings()
{
Container.BindInstance(arg);
}
}
The Argument
class:
public class Argument
{
public string val;
}
In the scene I have a SceneContext
that references the following installer:
using UnityEngine;
using Zenject;
public class SceneInstaller : MonoInstaller
{
public GameObject prefab;
public override void InstallBindings()
{
Container.BindFactory<Argument, Facade, Facade.Factory>()
.FromSubContainerResolve()
.ByNewContextPrefab<FacadeInstaller>(prefab);
}
}
where prefab
is linked in the inspector to the one I detailed above.
If I leave at that, the scene validates successfully.
Now the problem presents itself when I add another game object to the scene with the following component:
using UnityEngine;
using Zenject;
public class Creator : MonoBehaviour
{
[Inject]
Facade.Factory factory;
}
and the scene validations fails with the error:
ZenjectException: Unable to resolve 'Facade'. Object graph:
What's wrong with my setup?