How to pause your game in unity

While going through unity forums i have got to know that many people wanted to have a proper solution for pausing their games. In order to help them especially new bies i have made a package viz., MenuPackage.

It has a splash scene, a menu scene and a play again scene. It would help to know how to create a menu for the game. It would also help you to reuse it multiple times in your game(just in the developing phase).
The pause game and loadsettings scripts can be used with just any scene by just dragging and dropping.

The procedure for how to use this package is explained in the file with the attachment.
MenuPackage

You can find a WebDemo implementing this package here:
Working Web Demo

Downloadable Web Demo

Hope this package would help people out here.

According to me there can be some FAQs related to this package. So here are a few of them:

Q1. I got stuck at the splash scene. What to do?
or
I am getting an error saying Level MenuScene couldn’t be loaded.

Ans. You have not set all the scenes in your build settings. Apply the scenes in the build settings of your project in the mentioned order.

Q2. There is a field viz. background in the pauseGame and loadSettings script. What is its use?

Ans. The field represents the gameObject containing your background music. When user wants to put the music off from pause menu or from the main menu it must not get started when the level loads. So in order to achieve this functionality do the following procedure:

a) Uncheck Play On Awake property from the AudioSource having your background music

b) Assign this gameObject to the “background” field of the said scripts.

Q3. Where do i have to apply pauseGame and loadsettings?

Ans. You should apply these two scripts on an empty gameObject in your scene.

Any suggestions or questions are welcome.

Now you can easily use this package with EZGUI, the pauseScript has been simplified into functions which can easily be used EZGUI buttons and controls by just providing the name of the function and the gameObject containing that script.
The package also demonstrates how to fade in and out while switching from one scene to another.

Another new feature has been added to the package. You could implement a scrolling level box like the one you see in games like Angry Birds, Cut the Rope, etc.

Initially i mistakenly posted this thread with the title “how to pause game in unity” However i realised later that it would not help others to see this post as a helpful one. So i changed the title but it is still showing the same title in the search. Don’t know how to remove the post. I was also wondering to repost this thread with the new title then i dropped the !dea.

This looks very useful for the singleplayer devs here!
Do you have a video or screenshots you can show of ?

Currently, the link to your package above seems to be broken. :expressionless:

I have corss checked the link and its working absolutely fine.
[Don’t right click and save, instead just click on the link and then download the file]

I have a question. Will this also pause any currently running coroutines?

Yes. It will stop the execution of every script.

Hey ravinder,
thnx for the package is very usefull! p.s if you can upload a better quality video tutorial in youtube.

this pack rocks! thank you man

I will try to upload it soon.

such a great feature to share with us all, thank you Ravinder! :slight_smile:

the download link doesn’t work for me, looks like it might be expired :-(. Do you have another link?

Hello zhx. The link is not broken. its working fine. Do not try to save it by right clicking on it. Just click on it and then click on the download link.