Just in case anyone like me was wondering how to pause and resume the game, here is a very easy solution. Duplicate the “stop” button in the lecture twice and make a pause and play button. Then remove the current script and make a play script for the play button and a pause script for the pause button:
Here is the simple code:
public class Pause : MonoBehaviour {
void OnMouseDown() {
PauseGame ();
}
private void PauseGame()
{
Time.timeScale = 0;
}
}
then…
public class Play : MonoBehaviour {
void OnMouseDown() {
ContinueGame ();
}
private void ContinueGame()
{
Time.timeScale = 1;
//enable the scripts again
}
}
Enjoy!!!
1 Like
I had one small issue with this. When I paused my game then hit the stop button to return to the start menu, the panel with the fade in feature seems to stay paused resulting in a dark screen. Since I’m trying to finish up my game quickly, I simply prefabbed my panel then deleted it. Sacrificing the fade in for a pause game option was the fastest option and worth it for me. If anyone finds a different way to do this, please post for others.
I’ll update if I have any more issues as I get close to rendering my finale game. It’s going to be a cool undead invasion with lots of sprite phases (getting hit, dying and attacking) and audio just in time for Halloween!
1 Like