Search Unity

Resolved Weird behaviour when I try to Pause/Unpause Game with same button

Discussion in 'Input System' started by paulberta14, Jun 21, 2022.

  1. paulberta14

    paulberta14

    Joined:
    Jun 1, 2021
    Posts:
    2
    Hello guys,

    I am trying to Pause and Unpause the game using the ESCAPE button, but I encounter a strange bug.
    QxGVSTLCHu.png
    Pause-UnpauseGame.png

    When I have the code like this, it behaves how it's supposed to - It pauses the game when I press the pauseKey(ESC).

    If I uncomment the commented line in the Unpause method, the one that should hide the UI and set Time.timescale back to 1, (almost) everything breaks. The functionality from the PauseGame method that previously worked doesn't work anymore.
    When I uncomment the Debug.Log calls from the PauseGame method, the correct values are displayed, but nothing happens. The game isn't frozen although it says that Time.timeScale is 0.

    DebugLog.png

    These are the rest of the methods that are referenced in the screenshots posted above:
    OnResumePressed.png CloseAllMenus.png

    Any idea, piece of guidance, or reliable source that you think might help is very welcomed.
    Thank you for your time and attention!