IEnumerator WaitBeforeClosing(LobbyCloser closer) { while (netManager.numPlayers > 1) { Debug.Log("Waiting, currently connected players: " + netManager.numPlayers); yield return(new WaitForSeconds(0.01f)); } DestroyChat(); netManager.StopHost(); Destroy(gameObject); if (closer != null) { closer.Close(); } }
IEnumerator WaitToAuthorityRemoval(LobbyCloser closer) { if (!iAmServer) { NetworkIdentity netIdentity = GetComponent <NetworkIdentity>(); while (netIdentity.hasAuthority) { yield return(new WaitForSeconds(0.01f)); } NetworkServer.Destroy(GameObject.FindWithTag("LocalPlayer")); DestroyChat(); netManager.StopClient(); Debug.Log("Closing game..."); Destroy(gameObject); closer.Close(); } }