i have a main menu scene, that goes to the game scene without problems, but when i go back to the menu, the menu script doesn’t show. Any solutions?
Main Menu
private var canShow : boolean = false;
var Skin : GUISkin;
private var Name : String;
var playerName : String;
private var lastScore : int;
private var myscore : int;
function Awake()
{
Name = PlayerPrefs.GetString("MyName");
playerName = Name;
myscore = PlayerPrefs.GetInt("MyScore");
lastScore = myscore;
}
function Update()
{
Go();
}
function OnGUI()
{
//GUI.skin = Skin;
if(canShow == true)
{
if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2, 400, 100), "New Game"))
{
Application.LoadLevel(1);
}
if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2 + 100, 400, 100), "Quit Game"))
{
Application.Quit();
}
GUI.Box(Rect(0, 0, 200, 150),"Welcome Back");
playerName = GUI.TextField(Rect(50, 25, 100, 25), playerName, 10);
PlayerPrefs.SetString("MyName", playerName);
GUI.Box(Rect(50, 75, 100, 25), "Last Score");
GUI.Box(Rect(50, 100, 100, 25), lastScore.ToString());
}
}
function Go()
{
yield WaitForSeconds(2);
canShow = true;
}
Pause
private var paused : boolean = false;
function Awake()
{
Screen.lockCursor = true;
}
function Update()
{
if(Input.GetButtonDown(“Pause”))
{
if(Screen.lockCursor == false)
{
Screen.lockCursor = true;
Time.timeScale = 1.0;
MouseLook.sensitivityX = normalSensitivity;
MouseLook.sensitivityY = normalSensitivity;
paused = false;
}
else
{
Screen.lockCursor = false;
Time.timeScale = 0.0;
MouseLook.sensitivityX = 0;
MouseLook.sensitivityY = 0;
paused = true;
}
}
}
function OnGUI()
{
if(paused == true)
{
if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2, 400, 100), “Main Menu”))
{
Application.LoadLevel(0);
}
if(GUI.Button(Rect(Screen.width/2 - 200, Screen.height/2 + 100, 400, 100), "Quit Game"))
{
Application.Quit();
}
GUI.Box(Rect(Screen.width/2 - 100, Screen.height/2 - 100, 200, 50), "Paused");
}
}