Multiple NetworkManagers interfering with eachother on loaded scenes #464
Replies: 1 comment
-
Copy and pasting response from git issue. This is a tricky one because there's no way to really know which NetworkManager is intending to load the scene. My initial thoughts to get around this are to have the appropriate NetworkManager spawn the objects instead of making them scene network objects. Obviously, this is not ideal. The second idea I had was to search the FN SceneManager and see if the loaded scene was one handled by it. If so, then the NetworkManager knows it's responsible for the scene and can be the one to initialize the objects. If neither were able to find the scene as a loaded scene via FN SceneManager then they would both have to initialize. As a last effort go, each NetworkManager could see if the object was already initialized and warn for proper usage, and skip double initializing.. This would of course prevent the objects from working for that specific manager. |
Beta Was this translation helpful? Give feedback.
-
KartoffelbauerRebus
Unity version: 2021.3.16f1
Fish-Networking version: 3.6.1.Experimental.Pro
Describe the bug
NetworkObjects are randomly being initalized by different NetworkManagers than the one which loaded them in.
Diagnosis
When a new scene is loaded and all NetworkObjects in the scene are initialized, it is done through the global Unity SceneManager sceneLoaded event. With multiple NetworkManagers this becomes a free for all, since each one is not contained to only a local Fishnet SceneManager. See line 64 in ManagedObjects.cs.
Possible Solution
We have temporarily remedied this issue by instead subscribing to the SceneManager on the initialized managed object's NetworkManager. Then, we're changing the method's signature to match the new event in the overloads, after which we're iterating through SceneLoadEndEventArgs.LoadedScenes and adding them as they were before.
I would appreciate this being looked into and if not intended behaviour a proper fix applied, thank you.
Beta Was this translation helpful? Give feedback.
All reactions