You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for writing VContainer, we recently started using this in our game and it's a real lifesaver. There's just one issue I'd like your opinion on, we also use Unity's Netcode for GameObjects. We have several enemies that get spawned dynamically during a run. These Enemy NetworkObjects get synced over the network (by using the NetworkManager.SpawnManager). Both client and server have a LifetimeScope GameObject in the scene with the same set of registrations. Obviously I don't want to inject the dependencies on the server and send it serialized to the clients (that would definitely bring a world of hurt). I ended up with a solution where every dynamically created NetworkBehaviour has a line in its Awake method to tell VContainer to inject itself. Like so:
This still feels kind of icky, because the GameLifetimeScope is now a Singleton that lives outside of the whole Dependency Injection framework (because I can't get an instance of the IObjectResolver any other way).
I also looked at Unity's Boss Room (https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop) example which uses VContainer in combination with Netcode for GameObjects. Which also doesn't really solve the issue in a very clean way. Do you have any thoughts or suggestions on the topic?
Thanks!
The text was updated successfully, but these errors were encountered:
Hi there,
First of all, thanks for writing VContainer, we recently started using this in our game and it's a real lifesaver. There's just one issue I'd like your opinion on, we also use Unity's Netcode for GameObjects. We have several enemies that get spawned dynamically during a run. These Enemy NetworkObjects get synced over the network (by using the
NetworkManager.SpawnManager
). Both client and server have a LifetimeScope GameObject in the scene with the same set of registrations. Obviously I don't want to inject the dependencies on the server and send it serialized to the clients (that would definitely bring a world of hurt). I ended up with a solution where every dynamically created NetworkBehaviour has a line in its Awake method to tell VContainer to inject itself. Like so:This still feels kind of icky, because the GameLifetimeScope is now a Singleton that lives outside of the whole Dependency Injection framework (because I can't get an instance of the IObjectResolver any other way).
I also looked at Unity's Boss Room (https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop) example which uses VContainer in combination with Netcode for GameObjects. Which also doesn't really solve the issue in a very clean way. Do you have any thoughts or suggestions on the topic?
Thanks!
The text was updated successfully, but these errors were encountered: