Get rid of GUIButtons more efficiently

Hey everyone.

I am building my space tower defense game (cliched!) and am running into a funny issue :) Allow me to explain the situation. I have multiple boxes that I am using as turret spawn points, and am using the built in onGUI button ability in Unity to create buttons. My current workflow :

If you click on a button, it gets checked as "clicked" (boolean), meanwhile the onGUI checks to see if "clicked" is true. If it is true, it takes the last position that the mouse was (on the box) and create a GUI button on top of it. Everything works great! I added some code to make it so I can change clicked to false when I right click, or press escape, so that someone can click on a spawnbox, get the turret selection gui button, and if they choose not to click on a button they can right click off to the side somewhere and cancel out of the selection.

This all works great! However, I am looking for a way to turn off the buttons on a given spawnbox when ANOTHER spawnbox is pressed. At the moment, if I click on multiple spawnboxes, it makes multiple instances of the selection buttons until I click on an option or I right click cancel.

My current way of dealing with this is a function inside each spawnbox that I call each time a spawnbox is clicked. It creates an array of all the spawnboxes, and for each one sets "clicked" to false, and it is called before the "clicked" property is set to true for the one box I have clicked.

This works, but creating an array with each click just to change one property seems kind of a waste of resources. Is there a more efficient way to get rid of these buttons if I click on another spawnbox?

I'd suggest keeping track of the GUI's overall state and only displaying relevant buttons -

enum GUIStates {
  TurretSelection,
  TurretPlacement,
  Pause
  // etc.
}

var state : GUIStates = GUIStates.TurretSelection;

function OnGUI() {
  if ( clickedOnNothing ) state = GUIStates.TurretSelection;
  switch ( state ) {
    case GUIStates.TurretSelection: 
      // show turret choices
      break;
    case GUIStates.TurretPlacement:
      // etc.

A boolean global variable... something like "spawnBoxIsClicked". Define it in an unique object (something like "spawnRegulator"), and then each time a spawnbox is clicked, set it to true. When the click goes elsewhere (not on a box) or the GUI is used, set it back to false. Something like:

spawnRegulator.spawnBoxIsClicked = false;

should do the trick. This way you can either clear all boxes when you have a second click as true, or limit the player to clicking empty space before they can click the second box.

Personally i'd probably set up a separate single gui object (manager) and have the boxes call/broadcast to it when clicked. That way you have a single gui object/script dealing with your 'popup menu' display, making it far easier to manage the logic.