Question by
Zeewildthing · Apr 28, 2020 at 03:49 PM ·
c#programmingpausepause menu
Help with pause menu?
I am having some trouble when implementing a pause menu. Specifically it won't let me press the "resume" or "quit" button. I was hoping someone could help me with this. The specific code for the pause script is as follows:
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseGame : MonoBehaviour {
public GameObject playUI;
public GameObject pauseUI;
bool paused = false;
public string pauseButton;
void Update()
{
if(Input.GetKey(pauseButton))
pause();
}
public void pause() {
pauseUI.SetActive(true);
playUI.SetActive(false);
Time.timeScale = 0f;
paused = true;
}
public void resume() {
pauseUI.SetActive(false);
playUI.SetActive(true);
Time.timeScale = 1f;
paused = false;
}
}
I have double-checked that the buttons in the menu refer to the appropriate classes. Any help would be much appreciated.
Comment