Button is being triggered by spacebar after clicked once

I have a pause button in my space shooter game. When I pause, then un-pause, every time I use the space bar to shoot, it triggers the pause button. Is this because the pause button stays focused after being pressed once? Is it possible to un focus the button? I am using unity’s 4.6 GUI system.

Pause button code:

public void pause ()
    if (Time.timeScale == 1)
        Time.timeScale = 0;
        pauseText.enabled = true;
        Time.timeScale = 1;
        pauseText.enabled = false;

Any help in the right direction would be very much appreciated.

Sorry if irrelevant to you now but I thought I’d add for anyone else that comes across like me.

You can set the Navigation part of the UI.Button to None so it doesn’t keep focus. It acts like a form so you can easily navigate from one UI element to another (like when you tab to other fields etc.) Mine was defaulted to automatic.

Unity version 5.0.0b18.


You need to create a bool and to trigger the pause on and off when required. Currently you are just scaling the time scale 1 and 0. You need to create a private or public bool and then enable and disable it to trigger the pause function. Hope it helps.

What’s happening is that you’re using the new input system, when the EventSystem is expecting the original/old input system. Changing the navigation will work, but the correct solution is to look at the Inspector window for your EventSystem. It will prompt you to use the new input system, and this will correctly fix your issue.