File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
Assets/BossRoom/Scripts/Client/UI Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using Unity . Multiplayer . Samples . BossRoom . Shared ;
2
3
using Unity . Multiplayer . Samples . BossRoom . Shared . Infrastructure ;
3
4
using UnityEngine ;
@@ -13,18 +14,31 @@ public class UIQuitPanel : MonoBehaviour
13
14
14
15
ApplicationController m_ApplicationController ;
15
16
16
- private bool m_QuitMode = true ;
17
+ bool m_QuitMode = true ;
17
18
18
19
[ Inject ]
19
- private void InjectDependencies ( ApplicationController applicationController )
20
+ void InjectDependencies ( ApplicationController applicationController )
20
21
{
21
22
m_ApplicationController = applicationController ;
22
23
}
23
24
24
- void OnEnable ( )
25
+ void Awake ( )
25
26
{
26
- m_QuitMode = SceneManager . GetActiveScene ( ) . name == "MainMenu" ;
27
- m_QuitButtonText . text = m_QuitMode ? "Exit Game?" : "Return to menu?" ;
27
+ SceneManager . sceneLoaded += SceneManagerOnsceneLoaded ;
28
+ }
29
+
30
+ void SceneManagerOnsceneLoaded ( Scene scene , LoadSceneMode loadSceneMode )
31
+ {
32
+ var currentGameState = FindObjectOfType < GameStateBehaviour > ( ) ;
33
+ if ( currentGameState != null )
34
+ {
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") ;
41
+ }
28
42
}
29
43
30
44
public void Quit ( )
You can’t perform that action at this time.
0 commit comments