PAUSE MENU in Unity



Learn how to make a pause menu using Unity!

As mentioned in the video, we’ve already created a start menu and a settings menu. Check them out:

Start menu:
Settings menu:

TextMesh Pro Video:
Get TextMesh Pro:

♥ Support Brackeys on Patreon:

····················································································

♥ Donate:
♥ Subscribe:

● Website:
● Facebook:
● Twitter:

········································­­·······································­·­····

Edited by Sofibab & LeBonques.

········································­­·······································­·­····

► All content by Brackeys is 100% free. We believe that education should be available for everyone. Any support is truly appreciated so we can keep on making the content free of charge.

········································­­·······································­·­····

♪ Baby Plays Electro Games

Nguồn: https://100kuskov.com/

Xem thêm bài viết khác: https://100kuskov.com/game/

26 thoughts on “PAUSE MENU in Unity

  1. my game keeps flashing my menu with this:
    using System.Collections;

    using System.Collections.Generic;

    using System.Threading;

    using UnityEngine;

    public class PMenuScript : MonoBehaviour

    {

    public static bool IfPaused = false;

    public GameObject pauseMenuUI;

    // Update is called once per frame

    void Update()

    {

    if (Input.GetKeyDown(KeyCode.Escape)) ;

    {

    if (IfPaused)

    {

    Resume();

    }

    else

    {

    Pause();

    }

    }

    }

    void Resume()

    {

    pauseMenuUI.SetActive(false);

    Time.timeScale = 1f;

    IfPaused = false;

    }

    void Pause()

    {

    pauseMenuUI.SetActive(true);

    Time.timeScale = 0f;

    IfPaused = true;

    }

    }

  2. Hi, so when I pause the game for the first time I can continue it via the 'resume' button, but when I pause again and try to click the resume button, nothing happens… Anyone know a solution?

  3. In case you are having problems that the game start Paused or it just appear in a frame I got one solution Dont know if you want it (NOT TAKING THE PART OF THE BUTTON)
    public static bool GameIsPaused = false;

    public GameObject PauseGame;

    void Update()

    {

    if (Input.GetKeyDown(KeyCode.Escape))

    {

    if (GameIsPaused)

    {

    Resume();

    }

    else

    {

    Pause();

    }

    }

    }

    void Resume()

    {

    PauseGame.SetActive(false);

    Time.timeScale = 1f;

    GameIsPaused = false;

    }

    void Pause()

    {

    PauseGame.SetActive(true);

    Time.timeScale = 0f;

    GameIsPaused = true;

    }

  4. Im really confused its the second time this has happened the "Input.GetKeyDown" doesnt work for me, unity says "input does not contain a definition for GetKeyDown"

    ok so seems I have to quit unity. I cant do the get key down so I cant do a lot.. nice one. (I have gone through the video 3 times)

  5. Can you do a video about a pause button that shows the pause menu. When I tried the settings don't work

  6. I'm trying to get my game to pause in the background when I'm in the menu, it just won't work? Here's my menu script,
    using UnityEngine;

    using UnityEngine.SceneManagement;

    using System.Collections;

    using System.Collections.Generic;

    using System.Threading;

    public class MainMenu : MonoBehaviour

    {

    public void mainMenu()

    {

    SceneManager.LoadScene(0);

    }

    public void playGame()

    {

    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);

    }

    public void continueGame()

    {

    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

    }

    public void QuitGame()

    {

    Debug.Log("Quit!");

    Application.Quit();

    }

    }
    Plus, I can only click on my menu once per level for some reason? Thanks

  7. if your game is paused when you start use this code
    void Start()

    {

    pauseMenuUI.SetActive(false);

    Time.timeScale = 1f;

    GameIsPaused = false;

    }

  8. It doesn't work on 2019.4 version. You need to add the PauseMenu script to Canvas, for example. It doesn't work, bacause script doesn't work on a nonactive object. It needs to be active all the time.

  9. thanks brackeys for these teaching lessons i'm 12 years old and i make a game but i only have to do is to name it and make an icon and make some more levels and add audio thanks so much

  10. REMEMBER! If you want your Update() functions not getting your inputs, write

    if (PauseMenu.GameIsPaused) return;

    at the beginning of your Update(). Instead it will be getting them. And using FixedUpdate for your input system is a bad idea from my programming experience

  11. As you know main menu shown before game screen. So menu screen loaded before game screen. Is there any way to show previous loaded screen? In this tutorial, menu screen is loaded over again everytime.

Leave a Reply

Your email address will not be published. Required fields are marked *