Pause Menu Tutorial
03 November 2020
So today we are going to be making pause menus in unity.
Currently I am using Unity 2019.4.10
, So this can be applicable for future versions and maybe some older ones too.
I have a pre-prepared scene with only particles moving randomly.
Lets start by creating a C# script and call it GameManager.cs
so this is the default script you will get
You can remove both the comments.
First create a canvas with all the elements to be displayed when the game is paused and disable it.
Rename the canvas to PauseCanvas or what you choose.
We will use Time.timeScale to change the active state of the game.
When its value is 0 then the game will like stop and if it is 1 it will run properly.
It is like the speed of the game, it won`t work or move if it 0.
We will create 2 functions Resume and Pause and change the timeScale value here.
And we will modify the visibility of the pause menu too. So the with the additional code it will be
And we will disable the pause menu on start.
So this is the Final Script.
Now go into the unity editor and hit play.
Everything should work as expected.
Hit the Escape key to pause the game.