1

I'm trying to inject plain C# class into Mobobehaviour, but an "Unable to resolve 'HeightSystem' while building object with type 'UserDirijible'. Object graph: UserDirijible" exception is thrown.

namespace Systems {
    public class HeightSystem
    {
...
}
using Zenject;

namespace Systems {
    public class HeightSystemInstaller : MonoInstaller<HeightSystemInstaller>
{
    public override void InstallBindings()
    {
        Container.BindInstance<HeightSystem>(new HeightSystem()).AsSingle();
    }
}
}
//UserDirijible.cs
[Inject]
public Systems.HeightSystem heightSystem;

HeightSystemInstaller is attached to empty object in scene. What is may cause this error? Previously, Monobehaviour classes injection was work fine. I was mostly working with Dagger 2 and till now can not find the piece of documentation about injection plain C# classes into Monobehaviours

wingear
  • 819
  • 9
  • 21
  • 2
    Is your installer referenced by a context? (Scene context or GameObject context, attached to the gameObject holding the `UserDirijible` component – Hellium Feb 15 '20 at 16:20
  • Thanks, that was cause of error. I forgot about this – wingear Feb 15 '20 at 20:29

1 Answers1

3

Injected object was not attached to Scene context

wingear
  • 819
  • 9
  • 21