Problem Scene specific / maybe unanswerable
Pause menu works in editor but not after the game is built. (New Developer)
I'm fairly new to unity (and programming in general), and I've been working on a little game for a few weeks now that's almost complete. I'm running into a strange issue with the pause menu script that I created, where it seems to work perfectly fine in the editor (game pauses, menu shows up, button seems to work fine) but when I build the game to test things out it does absolutely nothing.
Here's the script for the pause manager that's in each scene
(OnPause is sent by the input system):
public class PauseManager : MonoBehaviour
{
public GameObject pauseMenuPrefab;
private GameObject pauseMenu;
private bool paused;
private void Awake()
{
paused = false;
}
private void OnPause()
{
Debug.Log("Game Paused");
if (!paused)
{
Time.timeScale = 0;
pauseMenu = (GameObject)Instantiate(pauseMenuPrefab);
paused = true;
}
else if (paused)
{
Destroy(pauseMenu);
Time.timeScale = 1;
paused = false;
}
}
}
I'm not the best programmer in the world, obviously. (And from what I've read setting the time scale to 0 is bad pause menu etiquette. What can you do...) Every other time I've used Instantiate to bring up UI elements it has worked fine in the editor and the build, and all of the other scripts dealing with the input system are issue-free. I'm curious as to why this works in the editor and then fails to do anything at all in the build.
All I'm really trying to do is give myself a way to close the application without having to Ctrl+Alt+Delete every time I test it out, so all pause menu wisdom is welcome and appreciated. I understand that I've kind of already made a Kronenberg of a pause script, as I said I'm very new to this.
Follow this Question
Related Questions
how can player move only on given path with keyboard input 0 Answers
how do i add script folder to final build 0 Answers
How can i ask a user for their name? 1 Answer
How to make UI Button serves as buttons for Input.getAxis()? 0 Answers
Gamepad input in UI stop working after a new panel cover the first one 0 Answers