VContainer
VContainer copied to clipboard
Injecting into MonoBehaviours Issues
When i call InjectGameObject in parent object to inject in to child objects, it leads to error if child object depends on parent
For example
WindowsManager.cs [Inject] void Construct(LifeTimeScope scope) { Scope.Container.InjectGameObject(panel.gameObject); } --(var 1) Panel.cs [Inject] void Construct(LifeTimeScope scope , WindowsManager windowsManager) { //THIS IS LEAD TO ERROR InvalidOperationException: ValueFactory attempted to access the Value property of this instance. } --(var 2) [Inject] void Construct(LifeTimeScope scope ) { //NO ERRORS ALL FINE }
UPD: InjectGameObjects only works from start without errors, not even awake
I think this is expected behavior. The container cannot pass the parent object to the child object because the parent is in the "construction" phase. But maybe a more detailed error message is needed.