Unity crashes when disconnecting as host
Hi, I'm quite new to unity networking but I get this consistent problem: When i disconnect as host from the server, unity freezes, and i can only shut it down in the task manager. Im using Unity Matchmaking, and using client.Disonnect() to disconnect. Before that, I was using StopServer() and StopHost() if i was host and this was the weird part: when I changed it to .Disconnect() it worked, so i thought it was fine. But it only worked on the time when i changed it. Next time i launched unity and tried, it froze again when disconnecting. Any idea what is happening?
using UnityEngine; using UnityEngine.Networking; using UnityEngine.Networking.Match;
public class PauseMenu : NetworkBehaviour { #region Variables public static bool isOn = false;
private NetworkManager networkManager;
#endregion
#region Methods
private void Start()
{
networkManager = NetworkManager.singleton;
}
public void LeaveRoom()
{
networkManager.client.Disconnect();
}
#endregion
}
LeaveRoom() called when pressing a leave room button
Your answer
