GUI button click not working.

when player will click on object a dialogue box will appear , and then player will have to click on the button(ok) to remove the dialogue box.

but the issue is that when the player two times taps on ok button then the dialogue box is disappering it is not disappearing when clicked or tapped once.

please check the code and let me know what could be wrong …
i have used following code.

function OnMouseDown () {
issueGun = true;
}

   if(issueGun)
    {
    
		Time.timeScale = 0.0;    		
		Graphics.DrawTexture(Rect(Screen.width / 2 - 260, Screen.height / 2 - 100, 520,200), PauseGui);
		if(GUI.Button (new Rect(763,483,78,42),"",ok))
		{
			Time.timeScale = 1.0;
	    	        issueGun=false;
	    	
	    
	   		
	   		LEFTPla.transform.localRotation = Quaternion.Euler(0.0,363, 0.0);
	    	Scriptobj.GetComponent(CapsuleCollider).enabled = false;
  		}
	}

Thanks,
-Hims

You need to write button click in OnGUI().

void OnGUI() {
    if (GUI.Button(new Rect(10, 10, 150, 100), "I am a button"))
        print("You clicked the button!");
    
}

Then only it works. For drawing texture you can use GUI.DrawTexture .

Thanks.,

Ekta.