- Home /
Main menu button loads main menu level but it is Frozen!!!
Hello beginner programmer here. I borrowed a script online for a pause menu. Within the script i set the "quit" button to load my main menu scene. However when it loads the main menu gravity is not affecting my start and quit game buttons that are supposed to fall onto the screen. Also the wind zone i set up is not moving my trees along with the rain particles not falling. Now when i have the "pause" menu true of course i have time.timescale = 0 and i thought maybe i had to include Time.timescale = 1 when i press the quit button to set it back to active along with loading the main menu. However that did nothing. If anyone can fix this probably simple coding problem for me i would really appreciate it. Also here is the Cs script to reference.
using UnityEngine; using System.Collections;
public class pauseMenu : MonoBehaviour { public GUISkin myskin;
private Rect windowRect;
private bool paused = false , waited = true;
private void Start()
{
windowRect = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 200);
}
private void waiting()
{
waited = true;
}
private void Update()
{
if (waited)
if (Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P))
{
if (paused)
paused = false;
else
paused = true;
waited = false;
Invoke("waiting",0.3f);
}
if (paused)
Time.timeScale = 0;
}
private void OnGUI()
{
if (paused)
windowRect = GUI.Window(0, windowRect, windowFunc, "Paused");
}
private void windowFunc(int id)
{
if (GUILayout.Button("Resume"))
{
paused = false;
Time.timeScale = 1;
}
if (GUILayout.Button("Options"))
{
}
if (GUILayout.Button("Quit"))
{
Time.timeScale = 1;
Application.LoadLevel(0);
}
}
}