How to Pause and Resume game in Unity3D

How to create pause and resume button for our Unity games? It’s easy. In this video tutorial I will show you how to set up the Pause and Resume UI.

Here is the code used in this video (Create a new C# file and name it PauseResume, then paste this code):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PauseResume : MonoBehaviour

    public GameObject PauseScreen;
    public GameObject PauseButton;

    bool GamePaused;

    // Start is called before the first frame update
    void Start()
        GamePaused = false;

    // Update is called once per frame
    void Update()
        if (GamePaused)
            Time.timeScale = 0;
            Time.timeScale = 1;

    public void PauseGame()
        GamePaused = true;

    public void ResumeGame()
        GamePaused = false;


Leave a Reply

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