Adding Tweens to the pause menu
Now that we have the main menu finished, let's continue doing this with the pause menu:
- Go ahead and open up our
Gameplay
scene. Update thePauseScreenBehaviour
script to have the following implementation ofSetPauseMenu
:
/// <summary>
/// Will turn our pause menu on or off
/// </summary>
/// <param name="isPaused"></param>
public void SetPauseMenu(bool isPaused)
{
paused = isPaused;
// If the game is paused, timeScale is 0, otherwise 1
Time.timeScale = (paused) ? 0 : 1;
if(paused)
{
SlideMenuIn(pauseMenu);
}
else
{
SlideMenuOut(pauseMenu);
}
}
Note that because PauseMenuBehaviour
inherits from MainMenuBehaviour
, it also can call the SlideMenuIn
and SlideMenuOut
functions, respectively, as long as they are marked as protected
or public
.
- Now if we run the game, nothing will appear to happen when we hit the pause menu. This is because—as I mentioned previously—Tweens are scaled by
Time...