Advertisement
johnnygoodguy2000

PauseMenu.cs

Apr 14th, 2024 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class PauseMenu : MonoBehaviour
  7. {
  8.    
  9.     public string mainMenuLevel;
  10.  
  11.     public GameObject pauseMenu;
  12.     public void PauseGame()
  13.     {
  14.         Time.timeScale = 0f;
  15.         pauseMenu.SetActive(true);
  16.     }
  17.  
  18.     public void ResumeGame()
  19.     {
  20.         Time.timeScale = 1f;
  21.         pauseMenu.SetActive(false);
  22.     }
  23.  
  24.  
  25.     public void RestartGame()
  26.     {
  27.         Time.timeScale = 1f;
  28.         pauseMenu.SetActive(false);
  29.         FindAnyObjectByType<GameManager>().Reset();
  30.        // GameManager.instance.RestartGame();
  31.     }
  32.  
  33.     public void QuitToMain()
  34.     {
  35.         Time.timeScale = 1f;
  36.         SceneManager.LoadScene(mainMenuLevel); // Replace Application.LoadLevel with SceneManager.LoadScene
  37.     }
  38.    
  39. }
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement