Reputation: 31
So I just managed to integrate Unity Mirror with FizzySteamworks as transportation layer.
My networkmanager is initialized in the offline scene (a main menu) and once I click "Play Game" everything works correctly until I quit (which I do by calling the method networkManager.StopHost()
). This moves me to the offline scene, but whenever I press play again I get the following error: InvalidOperationException: Steamworks is not initialized.
Is it possible that I disconnect/quit the game in a wrongful way? Should I disconnect via steamworks (Fizzy) instead?
Why is the SteamWorks API initialized only the first time when I enter the Main Menu and not the second?
Upvotes: 0
Views: 2327
Reputation: 31
I had to enable "Persist Network Manager To Offline Scene".
However, this added another problem whereas clients could not re-host a session if they had been automatically kicked from a previous session (kicked from the host quitting).
I noticed that SteamMatchmaking.LeaveLobby() didn't run on the client's side once a host auto kicks clients by calling a quit.
I therefore added a ClientRpc call from my DisconnectHost() method to make sure all clients left the Steam lobby before anyone lgot kicked by a host
.
Upvotes: 1
Reputation: 199
You shouldn't destroy your Steam API's manager. Steam API must be initialized before you try to use it. You can set the manager to "do not destroy on load". The only way Steam API is destroyed is only when the whole game closes, not just changing scenes. In short it should be initialized once you game starts and set as do not destroy on load.
Upvotes: 1