Pause Menu Buttons with Input System UI

I want to preface this with that I haven’t used Unity since the Input Manager and “GetKeyDown” was used in the scripting. This whole new Input System feels very over-complicated to me but that is definitely because I don’t fully grasp the concept. That being said I have made a 2D side-scrolling game where the player can walk down a hallway and interact with objects along the way. So far the player controls are working fine for me.

The problem comes from implementing my pause menu. Within the script I have:

void Start()
{
controls.PlayerControls.Pause.performed += _ => OnPause();
}

public void OnPause()
{
    if (!gamePaused) {
        pauseMenuUI.SetActive (true);
        Time.timeScale = 0f;
        gamePaused = true;
    } else {
            pauseMenuUI.SetActive (false);
            Time.timeScale = 1f;
        gamePaused = false;
    }
}

When the game is playing I am able to hit “P” for pause and my pause menu shows on screen.


The button that is supposed to be highlighted is (Resume) but that’s the only evidence that my Event System attached to the “PauseMenu” panel works. Here is what the PauseMenu panel Inspector looks like:

It does not respond to my mouse hovering over the buttons it does not respond if I press “P” again to exit the pause screen, I can’t use the arrow keys to select the button underneath it. Nothing happens. I have tried reading the documentation on the Input System and the UI Input Module Script but that just confuses me even more.I am sure there is something that I am missing somewhere but if anyone can help me out with this I would be so appreciative. :slight_smile: If any additional screenshots are needed let me know.

this isn’t an issue with the input system. you are setting the timeScale to 0 which stops the game moving forward. Unity - Scripting API: Time.timeScale

Uhmm okay but that doesn’t really answer the question. How would we be able to register inputs while the game is paused?

1 Like

I will try not setting it to 0 but I am thinking exactly what the guy above said. The timeScale setting to 0 shouldn’t affect a mouse click or anything, should it? Either way what would a work around be? There has to be some way to get this to work on the new unity input system thats more streamlined.

Update: I tried not setting the timeScale to 0 but that didn’t do anything for me. I think I need to somehow switch the Action Map to the UI Input Mode. Or something along those lines…

1 Like

Hey Millex756, could you figure out how to solve this issue?
Today I ran excatly into the same issue as you have described before.
Really the excact same problem. :roll_eyes:

EDIT:
Here you can find the solution:

2 Likes