controlling GUI.Button state

How do I control a GUI button state?

I want to have a button that remains active until I press another button.

You can use something like this:

   public class guiTest : MonoBehaviour {

public bool pressedbool = false;
	void OnGUI(){
			if(GUILayout.Button("press me to show your secrets", GUILayout.Width(400))){
				pressedbool = true; 
			if(GUILayout.Button("OMG I DONT WANT TO SEE THAT", GUILayout.Width(400))){
				pressedbool = false;
	public void pressed(){
		GUILayout.Label("you have pressed the first button, press the second button and this will dissapear");




you can use the toggle:

though, if you want unity to see if you’re hovering over a gui element it becomes something else, im not quite sure on how to do it, but this link might help, there’s some posts with code down the page, which seems to work, in theory at least :slight_smile: