How to Create a Pause Menu in Unity — Full Tutorial (With Working Buttons!)

Опубликовано: 15 Март 2026
на канале: DevSpark
708
17

Learn how to create a fully functional Pause Menu in Unity with working buttons! In this tutorial, I walk you through setting up a simple and effective pause system that includes buttons for Resume, Main Menu, and Quit.

What you'll learn:
How to pause and resume the game
How to use static variables
How to create full functional buttons

FULL SCRIPT:

using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManagerBehavior : MonoBehaviour
{
[SerializeField]
GameObject pauseMenu;

public static bool isPaused;

// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
pauseMenu.SetActive(false);
isPaused = false;
}

// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (!isPaused)
{
PauseGame();
}
else
{
ResumeGame();
}
}
}

private void PauseGame()
{
pauseMenu.SetActive(true);
isPaused = true;
Time.timeScale = 0f;
}

public void ResumeGame()
{
pauseMenu.SetActive(false);
isPaused = false;
Time.timeScale = 1f;
}

public void MainMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("MainMenu");
}

public void QuitGame()
{
Application.Quit();
}
}

#Unity #GameDev #PauseMenu