Skip to content

Commit ddce2a2

Browse files
committed
Only check for game state when loading in single mode
1 parent b9a8bed commit ddce2a2

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Assets/BossRoom/Scripts/Client/Game/State/ClientLoadingState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
public class ClientLoadingState : GameStateBehaviour
55
{
6-
public override GameState ActiveState { get { return GameState.Loading; } }
6+
public override GameState ActiveState => GameState.Loading;
77
}

Assets/BossRoom/Scripts/Client/UI/UIQuitPanel.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ void Awake()
2929

3030
void SceneManagerOnsceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
3131
{
32-
var currentGameState = FindObjectOfType<GameStateBehaviour>();
33-
if (currentGameState != null)
32+
// If switching to new scene, check current game state to determine quit mode
33+
if (loadSceneMode == LoadSceneMode.Single)
3434
{
35-
m_QuitMode = (currentGameState.ActiveState == GameState.MainMenu);
36-
m_QuitButtonText.text = m_QuitMode ? "Exit Game?" : "Return to menu?";
37-
}
38-
else
39-
{
40-
Debug.LogError($"Scene {scene.name} does not contain a GameStateBehavior");
35+
var currentGameState = FindObjectOfType<GameStateBehaviour>();
36+
if (currentGameState != null)
37+
{
38+
m_QuitMode = (currentGameState.ActiveState == GameState.MainMenu);
39+
m_QuitButtonText.text = m_QuitMode ? "Exit Game?" : "Return to menu?";
40+
}
41+
else
42+
{
43+
Debug.LogError($"Scene {scene.name} does not contain a GameStateBehavior");
44+
}
4145
}
4246
}
4347

0 commit comments

Comments
 (0)