Question by
nightsharks · Nov 05, 2018 at 01:08 PM ·
uibeginnerpause menubasic
pause menu: time stop works, but setActive doesn't
New to this, sorry! Everything's running fine and dandy, but when I hit the "pause" button, the pause menu UI doesn't appear. Timescale works as it should, and the Pause button disappears as well. Somehow, PauseMenuUI.setActive(true) isn't working as intended. Any suggestions?
PauseMenuUI is attached to the pause panel game object.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour {
public static bool GameIsPaused = false;
public GameObject PauseMenuUI;
public GameObject PauseButton;
public void Start()
{
PauseMenuUI.SetActive(false);
}
public void ButtonPress()
{
if (GameIsPaused)
{
Resume();
}
else
{
Pause();
}
}
public void Resume()
{
PauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
PauseButton.SetActive(true);
}
public void Pause()
{
PauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
PauseButton.SetActive(false);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612181549im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I get my pause menu to not be in the way of the Main Menu. 1 Answer
Is there a way I can make one script for all my buttons in my game? 1 Answer
Scripts Interfering With Each Other 1 Answer
[Beginner] [UI text] Adapt the size of the text zone to the text inside 2 Answers
How to limit the max and minimum number in a input field. 1 Answer