- Home /
Question by
caleb_b · Apr 22, 2014 at 11:04 PM ·
c#pause menuguibuttonbuilt
GUIButton menu is in wrong place in built version of my game
I have this code for a pause menu, which works well.
using UnityEngine;
using System.Collections;
public class Menu : MonoBehaviour
{
public Rect windowRect = new Rect(295,175,0,0);
public bool gamePaused = false;
void Update()
{
if(Input.GetKeyUp(KeyCode.Escape))
{
if(gamePaused)
{
gamePaused = false;
Time.timeScale = 1.0f;
} else
{
gamePaused = true;
Time.timeScale = 0.0f;}
}
}
void OnGUI()
{
if (gamePaused)
{
Time.timeScale = 0.0f;
GUILayout.Window(0, windowRect, PauseMenu,"Game Paused ", GUILayout.Width(100));
}
}
void PauseMenu(int windowPause)
{
if (GUILayout.Button("Resume"))
{
Time.timeScale = 1.0f;
gamePaused = false;
}
if (GUILayout.Button("Main Menu"))
{
Application.LoadLevel("MainMenu");
}
if (GUILayout.Button("Exit"))
{
Application.Quit ();
}
}
}
In the Unity program, I can move the menu around by changing the numbers (295,175 by default). My problem occurs after I build. Everything works, but when I am playing the built version, I pause and the menu is all the way in the top lefthand corner of the screen, regardless of where I have it positioned in Unity before the build. Any ideas to make the Menu be in the center of the screen in the built version?
Comment