1

I have a ScriptableObjectInstaller

public class Settings : ScriptableObjectInstaller<Settings>
{
    [Header("Gravity settings")] public GravityHandler.Settings GravitySettings;
    [Header("Movement settings")] public MovementHandler.Settings MovementSettings;

    public override void InstallBindings()
    {
        Container.BindInstance(GravitySettings);
        Container.BindInstance(MovementSettings);
    }
}

and a class

public class GravityHandler : IGravityHandler
{
    private readonly Settings _settings;
    private readonly BoxCollider2D _groundBox2D;

    public GravityHandler(BoxCollider2D groundBox2D, Settings settings)
    {
        _groundBox2D = groundBox2D;
        _settings = settings;
    }

    public bool IsGrounded()
    {
        if (_groundBox2D.OverlapCollider(_settings.ContactFilter2D, null) > 0)
            return true;
        return false;
    }

    [Serializable]
    public class Settings
    {
        public ContactFilter2D ContactFilter2D;
        public Vector3 GravityForce=new Vector2(0, -9.8f);
    }
}

All I want is to be able to change Settings.GravitySettings, and then inject its value into GravityHandler._settings, so i can use the settings inside GravityHandler. But when I validate my scene it shows me an error:

ZenjectException: Unable to resolve type 'GravityHandler+Settings' while building object with type 'GravityHandler'. Object graph: Player MovementHandler GravityHandler

What do I do wrong and how to fix this?

derHugo
  • 83,094
  • 9
  • 75
  • 115
Chaz Ashley
  • 389
  • 1
  • 15

1 Answers1

1

Okay, I just forgot to put the scriptable object into SceneContext. I also had to change its name to match the name of the class.

Chaz Ashley
  • 389
  • 1
  • 15