//check network connect function, when not receive server reply in last 5s, reconnect to server public void CheckHeartBeat() { //return; while (true) { if (CheckConnectVar) { CheckConnectVar = false; } else { //reconnect to server Debug.Log("re start connect at thread " + Thread.CurrentThread.ManagedThreadId); Loom.QueueOnMainThread(() => { if (SceneManager.GetActiveScene().buildIndex != 0) { Debug.Log("When lost connection, return to main scene, if you want close this feature, annotate these codes"); SceneManager.LoadScene(0); } }); NetCore.ReConnect(); } Thread.Sleep(6000); } }