diff --git a/Assets/Scripts/OnlineSessionBrowserUI.cs b/Assets/Scripts/OnlineSessionBrowserUI.cs
index e0cafea..8ea320d 100644
--- a/Assets/Scripts/OnlineSessionBrowserUI.cs
+++ b/Assets/Scripts/OnlineSessionBrowserUI.cs
@@ -20,10 +20,12 @@ using UnityEngine.InputSystem;
///
/// Overlay behaviour: the panel is always shown in Main (not connected). Once a connection is up it hides;
/// in the lobby/map Esc toggles it back as a modal pause overlay (cursor freed, local gameplay suspended via
-/// ). On the map the Disconnect button becomes "Back to Lobby" for the
-/// match authority (ends the match), while everyone else (in the lobby, or a non-authority client on the map)
-/// gets a plain disconnect. Only the visual is toggled - this binder stays alive on
-/// its (always-active) canvas so it keeps reading Esc while the panel is hidden.
+/// ). The Disconnect button is context-sensitive: in Main (not
+/// connected) it is an application "Exit" (quits the build, or stops play mode in the editor) so the player
+/// can leave without Alt+F4; on the map it becomes "Back to Lobby" for the match authority (ends the match);
+/// everyone else (in the lobby, or a non-authority client on the map) gets a plain disconnect. Only the
+/// visual is toggled - this binder stays alive on its (always-active) canvas so it
+/// keeps reading Esc while the panel is hidden.
///
public class OnlineSessionBrowserUI : MonoBehaviour
{
@@ -142,6 +144,14 @@ public class OnlineSessionBrowserUI : MonoBehaviour
{
if (!manager) return;
+ // In Main (no session) the button is an application Exit, so the player can quit the build
+ // without Alt+F4.
+ if (!manager.IsConnected)
+ {
+ QuitApplication();
+ return;
+ }
+
// On the map, the match AUTHORITY's button means "Back to Lobby" (end the match for everyone)
// rather than leaving the session. Everyone else - in the lobby, or a non-authority client on the
// map - does a plain disconnect.
@@ -155,6 +165,15 @@ public class OnlineSessionBrowserUI : MonoBehaviour
manager.Disconnect();
}
+ private static void QuitApplication()
+ {
+#if UNITY_EDITOR
+ UnityEditor.EditorApplication.isPlaying = false;
+#else
+ Application.Quit();
+#endif
+ }
+
private void OnManagerChanged()
{
if (!manager) return;
@@ -192,8 +211,13 @@ public class OnlineSessionBrowserUI : MonoBehaviour
private void RefreshDisconnectLabel()
{
if (!_disconnectLabel) return;
- bool backToLobby = _match && _match.IsLocalSceneMap && _match.IsLocalMatchAuthority;
- string text = backToLobby ? "Back to Lobby" : "Disconnect";
+ string text;
+ if (!(manager && manager.IsConnected))
+ text = "Exit"; // Main: quit the application
+ else if (_match && _match.IsLocalSceneMap && _match.IsLocalMatchAuthority)
+ text = "Back to Lobby";
+ else
+ text = "Disconnect";
if (text != _disconnectText)
{
_disconnectText = text;
@@ -211,7 +235,8 @@ public class OnlineSessionBrowserUI : MonoBehaviour
if (hostButton) hostButton.interactable = !busy && !connected;
if (refreshButton) refreshButton.interactable = !busy && !connected;
if (joinButton) joinButton.interactable = !busy && !connected && hasSelection;
- if (disconnectButton) disconnectButton.interactable = !busy && connected;
+ // Usable whenever idle: connected -> Disconnect / Back to Lobby; in Main -> Exit.
+ if (disconnectButton) disconnectButton.interactable = !busy;
}
private void RebuildList()