Only showing one GUI box at a time

I've got a bunch of planets for my game. If you click one, a GUI box pops up showing its stats and whatnot. However, this GUI box pops up for all my planets, displaying all of their names and info. This is bad. How do I prevent it from happening? Here's my current code:

function OnGUI() {
    if (planetWarpWindow) {
        var travelWindow = new Rect (0,0,Screen.width, Screen.height);
        GUI.Box (travelWindow, gameObject.name);
    }
}

Thanks, Elliot Bonneville

Hi,

If I understand correctly, you have this code on each of your planet.

One solution would be to have another private boolean variable that would be true only when the user has clicked on a planet, your window covers all the screen so I guess you can't clicked on another planet if a window is displayed, so that would be fine ( else you would need a manager or some communication going on to close previous window).

One other solution would be to have a specific script for dealing with the gui, and then have your planets to send messages one way or the other to your gui script. This is how I deal with this, I create a empty gameObject named "--- gui manager ---" or something, attach the script that will show the gui window and from other components I send messages to it OR if your gui script has static functions, call it directly. If you need a more complete example, I can provide.

Hope it helps,

Jean