Destroy GUI after Paused Game
Posted: 03:21 PM 1 Hour Ago
Hello,
here is the escript to pause with the GUI:
var pauseUI: Transform;
function Update ()
{
if (Input.GetKey (KeyCode.Menu)) {
pause ();
}
}
function pause () {
Time.timeScale = 0;
Instantiate (pauseUI);
}
How Do I Destroy the GUI after I put the Time.timeScale = 1; ? thanks for the help
system
May 14, 2012, 11:51pm
2
Psuedo code:
isPaused = false;
function awake()
{
isPaused = false;
}
function update()
{
//If pause is hit, make isPaused=true;
//If pause is hit again, or unpause, w/e, make isPaused = false;
}
function update()
{
//If (isPaused)
//Draw pause menu.
//else
//Draw game graphics.
}
Rough and unformatted, but works.
var pauseUI : Transform;
private var pauseInstance : Transform;
function pause () {
Time.timeScale = 0.0;
pauseInstance = Instantiate (pauseUI) as Transform;
}
function unPause () {
Time.timeScale = 1.0;
if (pauseInstance != null)
Destroy(pauseInstance.gameObject);
}
About Instantiate & prefabs
Object.Instantiate()
I found the solution simply
Search for the UI then destroy it. It would be best if you give the tag That UI (“UI”)
Destroy (GameObject.FindWithTag (“UI”)),