@@ -29,9 +29,9 @@ public class JCS_PauseManager : JCS_Manager<JCS_PauseManager>
2929 [ ReadOnly ]
3030 private float mTimeScale = 1.0f ;
3131
32- [ Tooltip ( "Test this module? " ) ]
32+ [ Tooltip ( "Turn on to test this behaviour. " ) ]
3333 [ SerializeField ]
34- private bool mTestWithKey = false ;
34+ private bool mTest = false ;
3535
3636 [ Tooltip ( "Key to toggle game pause/unpause." ) ]
3737 [ SerializeField ]
@@ -139,7 +139,7 @@ private void Update()
139139#if UNITY_EDITOR
140140 private void TestPauseGame ( )
141141 {
142- if ( ! mTestWithKey )
142+ if ( ! mTest )
143143 return ;
144144
145145 if ( Input . GetKeyDown ( mToggleGamePause ) )
@@ -181,7 +181,7 @@ public void ResetState()
181181 mTargetTimeScale = mDefaultTimeScale ;
182182 Time . timeScale = mDefaultTimeScale ;
183183
184- PauseTheWholeGame ( false ) ;
184+ SetPause ( false ) ;
185185 }
186186
187187 /// <summary>
@@ -196,7 +196,7 @@ public void Pause()
196196 else
197197 Time . timeScale = 0.0f ;
198198
199- PauseTheWholeGame ( true ) ;
199+ SetPause ( true ) ;
200200 }
201201
202202 /// <summary>
@@ -211,20 +211,30 @@ public void Unpause()
211211 else
212212 Time . timeScale = mDefaultTimeScale ;
213213
214- PauseTheWholeGame ( false ) ;
214+ SetPause ( false ) ;
215215 }
216216
217217 /// <summary>
218- /// Pause/Unpause the whole game.
218+ /// Toggle between pause/unpause the game.
219219 /// </summary>
220- public void PauseTheWholeGame ( bool act = true )
220+ public void TogglePause ( )
221+ {
222+ if ( mPaused )
223+ Unpause ( ) ;
224+ else
225+ Pause ( ) ;
226+ }
227+
228+ /// <summary>
229+ /// Set pause/unpause the game.
230+ /// </summary>
231+ public void SetPause ( bool act = true )
221232 {
222233 foreach ( JCS_PauseAction pauseAction in mPauseActions )
223234 {
224235 if ( pauseAction == null )
225236 continue ;
226237
227-
228238 // NOTE(jenchieh): the act should be opposite with the
229239 // enable /disable.
230240
0 commit comments