I’ve got a simple multiplayer game working, using the tutorial. However, this handles Connect/Host from the scene’s OnGUI. I want users to be able to Network.Connect in a separate scene, then load the game scene depending on which scene the host is in. How can I get the scene name from the host before the network synchronizes and starts instantiating objects in my “connect” scene?
You can create a lobby scene or use this free Unity Lobby Scene: Unity Asset Store - The Best Assets for Game Making
From there, you can setup a game manager to place players on their respective scenes.
I would also recommend checking out the Merry Fragmas tutorial: https://unity3d.com/learn/tutorials/topics/multiplayer-networking/merry-fragmas-30-multiplayer-fps-foundation
These series are great, the latest at the time of this writing is Merry Fragmas 3.0
This is how I did it in my last game without a lobby; it sounds like what you want.
Start with SynchronizePlayers class (or put it on some other NetworkBehavior).
Set up an override to OnStartLocalPlayer()
Check whether this local player is the server, if not, run a command on the server.
The command should declare a string (“serverScene”) which gets the active scene name from the SceneManager (commands are only run on the host/server).
The command then calls a ClientRpc which takes the serverScene as a parameter.
The ClientRpc declares a string (“clientScene”) and sets it to the active scene name of the client.
if (clientScene != serverScene)
Mine was only 2 players, but in theory that should work for any number of players connecting to a host in a different scene.