Turning off ONE GUI button

Hello Everyone,

I’ve searched all over the internet for hours and can’t find the answer. I want my GUI.Button to disappear when I click it. I can’t seem to do it. Using enabled=false turns all GUI off, but I want only the button to disappear. Currently, after I click the button, the rest of my GUI appear, but right over the button, which stays visible.

I appreciate your help.
-Hyperion

Try using a bool.

using System.Collections;
using UnityEngine;

public class DisappearingButton : MonoBehavior
{
	protected bool showButton1 = true, showButton2 = true;
	
	public void OnGUI()
	{
		if(showButton1)
			if(GUI.Button(new Rect(10, 20, 100, 20), "Turn Off 1"))
				showButton1 = false;
		if(showButton2)
			if(GUI.Button(new Rect(10, 45, 100, 20), "Turn Off 2"))
				showButton2 = false;
	}
}