- Home /
GUI activate and destroy
hi
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?
Answer by Kleptomaniac · Mar 08, 2013 at 07:34 AM
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,
Klep
Awesome! $$anonymous$$ake sure to accept my answer so others can see that this was the correct solution. :)
Your answer
Follow this Question
Related Questions
Making a text box appear after a certain gameObject is destroyed 0 Answers
GUI destroy instantiated Objects 2 Answers
destroy object with gui box on collision 1 Answer
Free Gui solutions 2 Answers