0

I have an embedded Player class.

public class PlayerInstaller : MonoInstaller
{
    [SerializeField] private GameObject _playerPrefabs;
    public override void InstallBindings()
    {
        var player = Container.InstantiatePrefabForComponent<Player>(_playerPrefabs);
        Container.Bind<Player>().FromInstance(player).AsSingle();
    }
}

But right now it not work too, but it worked before

I'm trying to inject a second class from the same instance:

Container.Bind<PlayerMovement>().FromComponentOn(player.gameObject).AsSingle()

and many-many options

but it still throws an error

ZenjectException: Unable to resolve 'PlayerMovement' while building object with type 'Flipper'. Object graph: Flipper
zomgra
  • 1
  • 2
  • Did you create you scene context (Right Click inside the Hierarchy tab and select Zenject -> Scene Context) and added your installer there?. I would also try with `.NonLazy()`, that creates the instance even if the ContractType in the binding is not injected anywhere else – rustyBucketBay Mar 28 '23 at 22:03

0 Answers0