- Home /
Pause and Main Menu Problem
When I go onto the MainMenu scene I can click play and the game will load. But when I pause it and click on "Main Menu", it goes to the menu but I can't enter the game again. Does anyone know why?
Here is the script for the PauseMenu:
var menuHeight:float=500;
var menuWidth:float=500;
var buttonSpacing:float=25;
var MainMenu: String = "Main Menu";
var titleTexture:Texture2D;
var customSkin:GUISkin;
var customStyle:GUIStyle;
function OnGUI(){
GUI.skin = customSkin;
GUILayout.BeginArea(Rect(Screen.width/2-menuWidth/2,Screen.height/2-menuHeight/2,menuHeight,menuWidth),customStyle);
GUILayout.Space(50);
GUILayout.Label(titleTexture);
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Main Menu")){
Application.LoadLevel(MainMenu);
}
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Exit to Desktop")){
Application.Quit();
}
GUILayout.Space(buttonSpacing);
GUILayout.EndArea();
}
you need to show the code, it's defiantly a problem with the code.
Do you mean the Unity pause button? That's the function of the button, pause all your scripts.
i've got a code for a pause menu but i'm going to try a new one because it doesn't stop the mouselook.
And it isn't the built in Unity pause button its an added script
Answer by TheDarkVoid · Oct 14, 2012 at 04:10 PM
I would recommend doing something like this when you pause the game:
foreach( GameObject g in GameObject.FindObjectsOfType(typeof(GameObject))) { g.SendMessage("Pause"); } and this for unpauseing:
foreach( GameObject g in GameObject.FindObjectsOfType(typeof(GameObject))) { g.SendMessage("UnPause"); }
And add this to the scripts that you want to be paused:
public void Pause() { isPaused = true; } public void UnPause() { isPaused = false; }
then based on if isPaused == true, you can pause you scripts