- Home /
[SOLVED] How can I continue game on UI button press?
Hi everyone, I have a an issue with an in game pause menu I'm making. Currently I can pause the menu and I get the canvas with my UI elements up, one of which is a 'Continue' button. I cannot for the life of me figure out how to do this. I am 14 and quite the beginner so a simple answer would be greatly appreciated!
Observed Behaviour:
Pause menu will come up when the ESC button is pressed and the game will pause. When ESC is pressed again, the game will resume. All other buttons in the menu work with the exception of the Continue button.
Expected Behaviour:
When the ESC button is pressed the menu should come up, the game should pause and on click the continue button should continue the game.
Here is the code, line 11 is where it should go.
Canvas canvas;
void Start()
{
canvas = GetComponent<Canvas>();
canvas.enabled = false;
}
void Update()
{
if (//When the button is pressed...)
{
Pause();
}
}
public void Pause()
{
canvas.enabled = !canvas.enabled;
Time.timeScale = Time.timeScale == 0 ? 1 : 0;
}
}
Could you show me how I can do that, I can't figure out how I actually use that function.
Answer by getyour411 · Aug 22, 2015 at 03:01 AM
Use the OnClick function from Continue button to call Pause.
Your answer
![](https://koobas.hobune.stream/wayback/20220612000944im_/https://answers.unity.com/themes/thub/images/avi.jpg)