Unity-Technologies / multiplayer-community-contributions

Community contributions to Unity Multiplayer Networking products and services.
MIT License
415 stars 160 forks source link

Lobby.IsValid still true after calling Lobby.Leave() #252

Open MagnusMakesGames opened 2 months ago

MagnusMakesGames commented 2 months ago

Hello, I am having an issue with Lobby.Leave() in my game, when calling it, Lobby.IsValid is still true, and I can't join any other lobbies. Here is my Disconnect function:

public void Disconnect(bool returnToMenu = false) { Debug.Log("Disconnecting from lobby");

    if(NetworkManager.Singleton != null)
        NetworkManager.Singleton.Shutdown();

    if(currentLobby.HasValue)
    {
        currentLobby.Value.Leave();
        //currentLobby = null;
    }

    if(returnToMenu)
        SceneManager.LoadScene("MainMenu");
}

I have been trying to fix this issue for over a week now, if anyone knows of a solution please let me know!

MagnusMakesGames commented 2 months ago

I found a workaround, Replacing the NetworkManager, Facepunch Transport and my lobby script with a new one when the player returns to the lobby after calling the disconnect function seems to fix the problem.

MagnusMakesGames commented 2 months ago

Nevermind, after testing this with my friend, it seems to just crash my game when i try to join someone.