Replies: 1 comment
-
|
VContainer doesn’t have a Zenject-style A) “Optional” via TryResolve Register the data only on the host scope (optionally under a key), then probe for it in the next scene: Why this works: optional ctor deps aren’t supported in VContainer, but method/property injection + B) Null-object / conditional registration Another clean pattern is to always inject ILobbyData, but register a NullLobbyData on clients and a real one on host: This keeps your constructors strict (no “optional”) and removes branching from call sites. Notes / refs:
If this helps, please mark as Accepted — happy to tweak with your exact lobby flow. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My typical workflow, while building multiplayer games is to gather data from the clients in a lobby, for example, selected characters/cosmetics, then, on the host, inject this data to the next scene.
So, in the next scene, this data is expected somewhere, to use right prefabs for spawning etc. Using Zenject, I could use [InjectOptional] to ignore these dependencies on the clients, but, using VContainer, to not get exceptions, my only workaround is to use IObjectResolver instead, which hides dependencies and requires much more boilerplate.
Maybe I am missing something, or you have suggestions for a better architecture
Beta Was this translation helpful? Give feedback.
All reactions