GUI activate and destroy


I have created a button that when you click on it, it will display / create a GUI, but what I want to do is to create a different button that will destroy that GUI. How do I do this?

Hey there,

Although you have failed to present any code (which makes helping you that much harder) I can give you a generalised answer.

All you need to do is base your GUI rendering on a boolean conditional, so that it can it can be rendered and unrendered from multiple inputs. So for example:

bool foo = false;

void OnGUI () {

     if (GUI.Button(new Rect(10, 10, 10, 10), "Render")) {
          foo = true;
     } else if (GUI.Button(new Rect(30, 10, 10, 10), "Unrender")) {
          foo = false;

     if (foo) {
          //Render your GUI elements

Hope that helps,