I make my game using Zenject. I ran into a problem when restarting the scene at the death of the hero.
The hero's binds are currently in the SceneContext, but I want to use the Project Context to save the hero's states.
private void PlayerBindings()
{
//_player = ProjectContext.Instance.Container.Resolve<PlayerView>();
_player = Container.InstantiatePrefabForComponent<PlayerView>(Container.Resolve<ScriptableObjectService>().PlayerConfig.GetHeroValue().Player);
Container.Bind<PlayerView>().FromInstance(_player).AsSingle();
Container.Bind<PlayerInput>().AsSingle();
Container.Bind<PlayerModel>().AsSingle();
Container.BindInterfacesAndSelfTo<PlayerController>().AsSingle().WithArguments(_player);
}
If you implement hero binding in the ProjectContext, then when the scene is restarted, it freezes, most likely due to the fact that the hero is DontDestroyOnLoad.
Can you tell me how my idea can be realized?
I make my game using Zenject. I ran into a problem when restarting the scene at the death of the hero.
The hero's binds are currently in the SceneContext, but I want to use the Project Context to save the hero's states.
private void PlayerBindings()
{
//_player = ProjectContext.Instance.Container.Resolve<PlayerView>();
_player = Container.InstantiatePrefabForComponent<PlayerView>(Container.Resolve<ScriptableObjectService>().PlayerConfig.GetHeroValue().Player);
Container.Bind<PlayerView>().FromInstance(_player).AsSingle();
Container.Bind<PlayerInput>().AsSingle();
Container.Bind<PlayerModel>().AsSingle();
Container.BindInterfacesAndSelfTo<PlayerController>().AsSingle().WithArguments(_player);
}
If you implement hero binding in the ProjectContext, then when the scene is restarted, it freezes, most likely due to the fact that the hero is DontDestroyOnLoad.
Can you tell me how my idea can be realized?
That's settled. I initially did not understand the concept of Project Context. I started saving only some data about the Hero in it, by type: Health, level, etc.