Closed bubblebooy closed 7 months ago
I know this is old but in case your still battling with the error.
Duplicating objects across all scenes has a lot of messy issues like this especially with objects that need to persist like Steam's various managers, behaviours, etc.
Personally we advise against having an object like NM, Steam, Camera, etc. in every scene or even in a scene that gets loaded more than once such as a title scene. It bloats the scenes, requries unnessisary processing, etc.
Its simpler to have exsasctly 1 NM (and any other "manager" like behaviour) be intilized in your game (ever) and either use a "bootstrap" scene structure or mark the object as Do Not Destroy on load so its persisted in Unity's the scene Unity sets up for that. If you did such you wouldn't have the issue your facing, your scene would be a tiny be smaller and you would have less processing happening on scene load making for faster execution ... seems like a win win.
If your wondering what I mean by a bootstrap we have an article on that concept here https://kb.heathenengineering.com/company/concepts/bootstrap-scene
There are other ways of handling it of course but in general bloating every scene with every dependency causes issues, slows your game, bloats your scenes and genrally leads to bad times so I woudl recomend finding a way to not do that.
When you change scenes to a new scene with NetworkManager Mirror automatically destroys the duplicate NetworkManager GameObject.
The FizzySteamworks.cs on the NetworkManager GameObject then calls its OnDestory() method which calls Shutdown(). Since client and server are static the Shutdown method shuts down the connection.