public void Play() { if (ENetClient.IsConnected()) { SceneManager.LoadScene("Main"); ENetClient.InGame = true; } }
private IEnumerator CheckConnection() { while (!ENetClient.IsConnected()) { ConnectionAttempts++; Debug.Log($"Connection attempts: {ConnectionAttempts}"); if (ConnectionAttempts >= MAX_CONNECTION_ATTEMPTS) { Debug.Log("Failed after 10 connection attempts"); yield break; } yield return(new WaitForSeconds(CONNECTION_ATTEMPT_RETRY_DELAY)); } // Success ConnectionAttempts = 0; // Reset connection attempts / only fill it up again if client disconnects Debug.Log("Connection established"); }