Firstly, please excuse my posting a question on the Forum. It seems there are presently some login problems to the Questions area that prevent me from using it.
Scenario
Using the Network Lobby Manager from the Asset Store, I would like to run through the following 4-scene 2-player game sequence, on both a Host and Client (using either Manual Connection or Matchmaking) :
- Enter Scene 0 as a non-Lobby with no Lobby Manager present.
- Change to Scene 1 which is the Network Lobby (Lobby Manager created at this point).
- Host presses “Play and Host”
- Client Presses “Join”
- Now in the LobbyPanel both Host and Client press Join.
- Change to Scene 2 which is the Network game.
- Change to Scene 3 which is post game outside of the Lobby Manager (i.e. Lobby Manager has been destroyed).
- Change back to Scene 0.
- Progress back through to Step 6 (i.e. to play the game again).
The problem
At Step 4 (2nd time round after Step 9), the Host process works as expected, which is to say, the same as it did the first time through the sequence.
However, the Client joins the lobby then immediately errors with “A connection has already been set as ready. There can only be one.”
Here’s some context …
Software Components
- Unity 2017.1.1f1 Personal
- Asset Store Network Lobby
References Searched
Here is a list of resources I have used trying to find a solution to my problem.
Tutorials
Unity Questions and Forums
I have read a number of questions that are closely linked to the problem I am seeing. Here is just a taster :
- This question sees a similar error message that I am getting
- This question again sees a similar error message but is a self implemented solution
- This question seems to be the very same problem and says that there is a bug fix already reported. However that fix says it is in review as of 2015 (two years ago at the time of writing)
Example Solutions Attempted
I have tried various solutions. For example, one was to try doing this on the Server in the Game scene :
foreach (var slot in lobbySlots)
{
if (slot)
slot.readyToBegin = false;
}
My latest attempt has been to try this:
- At the end of the Game-scene, change the lobby to be the post-game-scene and switch the Server to that scene, like this:
[ServerCallback]
LobbyManager.s_Singleton.lobbyScene = "Post game";
LobbyManager.s_Singleton.ServerReturnToLobby();
- The Post-game-scene (client and server side) has this code:
void Start ()
{
StartCoroutine(ChangeScene());
}
IEnumerator ChangeScene()
{
var lobby = Object.FindObjectOfType<LobbyManager>();
float fTime = 3f;
if(!NetworkServer.active)
{
yield return new WaitForSeconds(fTime);
Debug.Log("StopClient");
LobbyManager.s_Singleton.StopClient();
}
else
{
while (Network.connections.Length > 0)
yield return null;
Debug.Log("StopHost");
LobbyManager.s_Singleton.StopHost();
}
yield return new WaitForSeconds(fTime);
Debug.Log("Shutdown");
NetworkManager.Shutdown();
yield return new WaitForSeconds(fTime);
Debug.Log("Destroy");
DestroyObject(lobby.gameObject);
// Destroy(NetworkManager.singleton.gameObject);
}
Statement of the Question
From the tutorial links posted above and also from using the Asset Store Network Meteoroid project, it appears that all solutions using the Network Lobby Manager rely on having only 2 scenes, to wit: the lobby and the game. The code simply switches to and fro between these 2 scenes.
How then, for each of a Server, Host and Client, can the LobbyManager be properly closed down to allow changing to other scenes and then back to a new Network Lobby game? Or must I write an entire lobby manager from scratch to handle this?
Thanks for any assistance with this.