All I want is a way to choose what online level will be loaded. Maybe make it something players in a lobby can vote for, eventually.
I’ve spent enough time searching to assume that NetworkManager.ServerChangeScene is the answer, but I don’t know how it’s implemented. The advice I found is written for other knowledgeable programmers, which I am not. Nor are those asking, usually. Still, couldn’t hurt to try for myself.
If you could even just direct me to an example where this has been made to work, or tell me what to type where, I can figure out the rest. Please help. Thank you.
When you set your online/offline scene in NetworkManager, a method NetworkManager.ServerChangeScene is called automatically in the background. When this method is called, the NetworkManager.OnServerSceneChanged is called on the server and NetworkManager.OnClientSceneChanged is called on the clients. These methods can be overridden and customized. If you are using the networkmanager, you can get the instance of your networkmanager by writing NetworkManager.singleton.
So at the point where you would like to globally change your scene (server & clients), you should have something like:
void ChangeScene(string sceneName){
// Change scene on the server
NetworkManager.singleton.ServerChangeScene(sceneName);
}
In addition, according to the documentation you need to set clients to be ready again after changing the scene, so for example you could override the NetworkManager’s method:
public override void OnClientSceneChanged(NetworkConnection conn){
base.OnClientSceneChanged(conn);
// Set client as ready
ClientScene.Ready(conn);
}
A TOTALLY DIFFERENT MAYBE BETTER WAY! if anyone cares hahah =)
you can create Multiple Lobbys as Scenes with seperate instances of Lobby manager with play scene set to some different scene … then when you Host add a prefix onto match.name ie…
manager.matchName = "F_" + roomNameField.text ; // An InputField.text
Then when you check for rooms available, you can then only display rooms available to join that have the prefix at beginning ie.
Thus only Displaying Rooms with the PreFix “F” available to join, so use different PreFixes for different lobbies and Clients can then only connect to Matches in the required lobby =)