Draw / don't draw buttons based on boolean variable

I have a feeling I’m missing something really simple, but I can’t get this to work. I’m just having a menu item (quit) change to “sure?” after a click.

With the debug log in there it shows quitToggle is staying true, regardless of multiple clicks (it should at least change to false after 1 click, right?). But if I move the debug log to the other side of the variable change, it prints ‘false’ every click instead. I’m guessing its something to do with the variable not sticking around by the time the GUI updates next frame? Anyway, I’m stumped. Help appreciated, thanks!

I have my “public bool quitToggle = true;” after monobehavior but before void onGUI. I did try swapping it around in various places, but no luck. Sorry, I’m kinda new :smiley:

// Quit Game Button (ask if you're sure)
		if (quitToggle = true) {
			if (GUI.Button (new Rect (menuPosX+5,menuPosY+110, buttonSizeX, buttonSizeY), "Quit", darkStyle)) {
				quitToggle = false;
		// Yes I'm sure button
		if (quitToggle = false) {
			if (GUI.Button (new Rect (menuPosX+5,menuPosY+110, buttonSizeX, buttonSizeY), "Sure?", darkStyle)) {

Read up on the assignment operator = and the equality operator ==. Inside an if statement you almost always need the equality operator.