rematch use the same leave function, added a grace period for connection disconnect
This commit is contained in:
@@ -808,10 +808,22 @@ public class GameManager : NetworkBehaviour
|
||||
// LevelLoadManager.LoadLevel("MainMenu");
|
||||
}
|
||||
|
||||
public void Leave(){
|
||||
public void Leave(string levelName = "MainMenu"){
|
||||
NetManager.MarkIntentionalClientDisconnect();
|
||||
StopClient();
|
||||
LevelLoadManager.LoadLevel("MainMenu");
|
||||
|
||||
StartCoroutine(CoroutineWaitTillDisconnection(levelName));
|
||||
}
|
||||
|
||||
IEnumerator CoroutineWaitTillDisconnection(string levelName){
|
||||
LevelLoadManager.instance.Show(); //Load the UI until the level is loaded
|
||||
while(NetworkClient.isConnected){
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(1f); //Just to make sure
|
||||
|
||||
LevelLoadManager.LoadLevel(levelName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user