Clicks counting on main game and popup

Im working on a game that has a character you can click to make jump (imagine flappy bird type), it has a pause button on the screen. The problem is that when you click the pause button and then click through the various options in the pause menu its fine, but when you click to resume game the character jumps up of the screen as if the clicks from the pause menu have been carried over to the main character.

Is there a way of making sure the clicks are only counted on the pause menu popup or resetting the clicks so they don’t carry on to the main game?

Any help appreciated.

If you use OnGUI(), you can use the current Event:

if (Event.current.button == 0 && GUIUtility.hotControl == 0) {
					Event.current.Use();

If you game is quite simple, then it’s probably easiest if you just set a boolean to true if you are in any kind of menu, and set it to false when the game itself should receive input. Then, in your jump function, if the boolean is set to true (=in menu), just cancel the function / return.

You could create a boolean into your script that limit when the character can jump, for example

 var Paused : boolean;
    
    function Update() {
    if (Input.GetMouseButton(0)) {
        if (Paused == false) {
             //Jump
             }
        }
    }

Then in your Pause Menu Script add a line that changes the Paused variable when you enter in it.
And set it to false when you exit from it.

Try delaying the moment you close the menu until the LateUpdate, by that point every Update function that use the key being pressed in the current frame has already finished. Something like this should work:

public class PauseMenu : MonoBehaviour {
    
    bool shouldClose;

    public void Open() {
        gameObject.SetActive(true); //or whatever you do to open the menu
        shouldClose = false;
    }

    public void Close() {
        shouldClose = true;
    }

    void LateUpdate() {
        if (shouldClose) {
            gameObject.SetActive(false); //or whatever you do to close the menu
        }
    }

}

Hi all, thanks for all the suggestions, I tried them all but none helped, I found that the solution was to set the character to inactive when the pause button was clicked and then set it back to active when the resume button is clicked.