Fix retry after defeat
This commit is contained in:
parent
a26d0acbfb
commit
726af6d379
1 changed files with 15 additions and 3 deletions
|
|
@ -2169,10 +2169,22 @@ namespace TD.UI
|
|||
|
||||
// Fallback: LobbyService isn't spawned (e.g. testing the gameplay
|
||||
// scene standalone without the lobby flow). Hard-reload the scene.
|
||||
Debug.LogWarning("[HUDController] LobbyService not found — falling back to scene reload.");
|
||||
//
|
||||
// Do NOT reload via NetworkManager.SceneManager here. Reloading the
|
||||
// currently-active scene through NGO's networked scene manager in
|
||||
// Single mode deadlocks: SceneEventProgress unloads the active scene
|
||||
// then waits on a load-complete ack for the same scene handle it is
|
||||
// mid-transition on, which never arrives — the main thread hangs
|
||||
// (beachball). LoadSceneAsHost is safe only because it loads a
|
||||
// *different* scene (Lobby). With no LobbyService there is no real
|
||||
// multiplayer session worth preserving, so shut the host down and do
|
||||
// a plain, non-networked Unity scene reload instead.
|
||||
Debug.LogWarning("[HUDController] LobbyService not found — falling back to non-networked scene reload.");
|
||||
string activeScene = SceneManager.GetActiveScene().name;
|
||||
var nm = NetworkManager.Singleton;
|
||||
if (nm != null && nm.IsServer && nm.SceneManager != null)
|
||||
nm.SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
|
||||
if (nm != null && nm.IsListening)
|
||||
nm.Shutdown();
|
||||
SceneManager.LoadScene(activeScene, LoadSceneMode.Single);
|
||||
}
|
||||
|
||||
// Return to Main Menu: disconnect only this player. SessionFlow's
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue