File tree Expand file tree Collapse file tree 2 files changed +27
-20
lines changed Expand file tree Collapse file tree 2 files changed +27
-20
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ public class UIQuitPanel : MonoBehaviour
13
13
14
14
ApplicationController m_ApplicationController ;
15
15
16
+ private bool m_QuitMode = true ;
17
+
16
18
[ Inject ]
17
19
private void InjectDependencies ( ApplicationController applicationController )
18
20
{
@@ -21,14 +23,21 @@ private void InjectDependencies(ApplicationController applicationController)
21
23
22
24
void OnEnable ( )
23
25
{
24
- m_QuitButtonText . text = NetworkManager . Singleton != null && NetworkManager . Singleton . IsListening ?
25
- "Leave session?" :
26
- "Exit Game?" ;
26
+ m_QuitMode = NetworkManager . Singleton == null || ! NetworkManager . Singleton . IsListening ;
27
+ m_QuitButtonText . text = m_QuitMode ? "Exit Game?" : "Leave session?" ;
27
28
}
28
29
29
30
public void Quit ( )
30
31
{
31
- m_ApplicationController . QuitGame ( ) ;
32
+ if ( m_QuitMode )
33
+ {
34
+ m_ApplicationController . QuitGame ( ) ;
35
+ }
36
+ else
37
+ {
38
+ m_ApplicationController . LeaveSession ( ) ;
39
+ }
40
+
32
41
gameObject . SetActive ( false ) ;
33
42
}
34
43
}
Original file line number Diff line number Diff line change @@ -93,28 +93,26 @@ private bool OnWantToQuit()
93
93
return canQuit ;
94
94
}
95
95
96
- public void QuitGame ( )
96
+ public void LeaveSession ( )
97
97
{
98
- if ( NetworkManager . Singleton . IsListening )
98
+ m_LobbyServiceFacade . ForceLeaveLobbyAttempt ( ) ;
99
+
100
+ // first disconnect then return to menu
101
+ var gameNetPortal = GameNetPortal . Instance ;
102
+ if ( gameNetPortal != null )
99
103
{
100
- m_LobbyServiceFacade . ForceLeaveLobbyAttempt ( ) ;
101
-
102
- // first disconnect then return to menu
103
- var gameNetPortal = GameNetPortal . Instance ;
104
- if ( gameNetPortal != null )
105
- {
106
- gameNetPortal . RequestDisconnect ( ) ;
107
- }
108
- SceneManager . LoadScene ( "MainMenu" ) ;
104
+ gameNetPortal . RequestDisconnect ( ) ;
109
105
}
110
- else
111
- {
106
+ SceneManager . LoadScene ( "MainMenu" ) ;
107
+ }
108
+
109
+ public void QuitGame ( )
110
+ {
112
111
#if UNITY_EDITOR
113
- UnityEditor . EditorApplication . isPlaying = false ;
112
+ UnityEditor . EditorApplication . isPlaying = false ;
114
113
#else
115
- Application . Quit ( ) ;
114
+ Application . Quit ( ) ;
116
115
#endif
117
- }
118
116
}
119
117
}
120
118
}
You can’t perform that action at this time.
0 commit comments