- Home /
How to ignore Submit button when coming out of pause menu?
Hi, I'm making an action platformer that uses the Gamepad A button to jump when the game is running, and also as the 'Submit' button when in the pause menu. When I unpause with the Start button, everything works fine, however, my problem is that when I select 'Resume' from the pause menu with the A button(Sumbit button), the character jumps as Time.timescale becomes 1 again. I've got the following function attached to the Start and Gamepad A button:
public void Pause()
{
canvasGroup.interactable = !canvasGroup.interactable;
canvas.enabled = !canvas.enabled;
Time.timeScale = Time.timeScale == 0 ? 1 : 0;
}
The only solution I've come up with so far is to unpause the game in the Update function with the following statement:
void Update()
{
if (Input.GetButtonDown("Gamepad_A") && Time.timeScale == 0)
{
canvasGroup.interactable = false;
canvas.enabled = false;
Time.timeScale = 1;
}
if(Input.GetButtonDown("Gamepad_Start") || Input.GetKeyDown(KeyCode.Escape))
{
Pause();
}
}
This works, but creates a new problem which is that if I select another menu item, such as Options, the game will just resume instead of going to the options menu. I was thinking about trying to add another condition to the if statement such as && ResumeButton == highlighted, but I don't know how to access the buttons through code. Anyway, any ideas or tips would be greatly appreciated! Thanks for taking a look :)
Your answer
Follow this Question
Related Questions
Error in a really short script 2 Answers
Pause: Issues with pausing, resuming, and pressing buttons within pause 2 Answers
Game stays paused after Restart. 1 Answer
GUI Button appears when Paused 1 Answer