I’ve been scouring the internet trying to find if this issue has been resolved before, but to no avail.
I was trying to make a pause menu, which seemed simple enough. However, nomatter what I change Time.timeScale to it instantly reverts it back to 1…
after a while I tried manually changing it under Edit → Project Settings → Time, but it automatically reverts it back to 1 there too…
using UnityEngine;
using System.Collections;
public class PauseMenu : MonoBehaviour {
bool paused = false;
void Update ()
{
if ( Input.GetKeyDown( KeyCode.Escape ) )
{
Pause();
}
Debug.Log ( Time.timeScale );
}
void Pause()
{
paused = !paused;
Time.timeScale = 1.0f - Time.timescale;
}
void OnGUI()
{
if ( paused )
{
var rect = new Rect( 10, 10, 100, 30 );
rect.center = new Vector2( Screen.width/2, Screen.height/2 - 35 );
if ( GUI.Button( rect, "Return to Game" ) )
{
Pause();
}
rect.center = new Vector2( rect.center.x, rect.center.y + 35 );
if ( GUI.Button( rect, "Quit to Main Menu" ) )
{
// unpause / reset timescale before loading new scene
Pause();
Application.LoadLevel( "MainMenu" );
}
}
}
}
Edit:
I realized there was a Questions specific area for stuff and made a post there, but can’t figure out how to delete this thread…