Disable mouse click navigation when selecting GUI menu option

Hi, my problem is the following: I have a game where the player moves in a Diablo-like fashion, i.e. according to the player click on the map. The problem is that the player sometimes gets to talk to NPCs and, when clicking one of the possible answers, the menu button gets clicked but also the player starts running towards the point the map where the mouse button has been clicked. Now, I still want the player to be able to walk around with the mouse when a Dialogue menu pops up, but not when he clicks on a Dialogue option. I hope you understand what I mean, and that somebody of you knows an easy trick for this. Thanks in advance.

Use “GUIUtility.hotControl” as condition to check whether mouse is over GUI or not. GUIUtility.hotControl returns 0 if mouse is not over GUI and returns respective ID if mouse is over some GUI element.

 void Update()
    {
    if(Input.GetMouseButtonDown(0) && GUIUtility.hotControl == 0)
    {
    //Code
    }
    
    if(Input.GetMouseButton(0) && GUIUtility.hotControl == 0)
    {
    //Code
    }
    
    if(Input.GetMouseButtonUp(0) && GUIUtility.hotControl == 0)
    {
    //Code
    }
    }

I think this would help you…

Scripting reference