This question was
closed Dec 06, 2016 at 02:16 AM by
VHLS2 for the following reason:
The question is answered, right answer was accepted
Question by
VHLS2 · Dec 05, 2016 at 06:08 PM ·
scripting problemcanvasscalepause menu
hey im trying to make a pause menu, it keeps poping up at the start and i have no idea how to fix.
when i start up the game the canvas pops up, i dont know what im doing wrong: here is my canvas script
using UnityEngine; using System.Collections;
public class PauseGame : MonoBehaviour { public Transform canvas;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
Pause();
}
}
public void Pause()
{
if (canvas.gameObject.activeInHierarchy == false)
{
canvas.gameObject.SetActive(true);
Time.timeScale = 0;
AudioListener.volume = 0;
}
else
{
canvas.gameObject.SetActive(false);
Time.timeScale = 1;
AudioListener.volume = 1;
}
}
public void Exit(){
Application.Quit();
}
}
im trying to disable it at the start in game manger but it wont let me add it to the script. anyone have any idea they would be much appreciated
Comment
Answer by $$anonymous$$ · Dec 05, 2016 at 06:27 PM
I think that you should declare it as false in the Start method.
thanks, i tried that at the start but when i tried to activate it, there wasn't a pop up. after i rebooted unity it worked. thanks
@VHLS2 if you found the answer useful please accept it and vote up.