I have two gui buttons and I managed to shut one off if not in use, but when I click it. Well, the new button shows up over top of the first button instead of completely turning off the first. I cut out the code that goes in mywindow because it’s a complete mess. But getting rid of the Show Window button is what I’m trying to do. I can’t seem to get it to go away after it shows the window.
public class ChangeColour : MonoBehaviour {
private bool render = false;
private Rect windowRect = new Rect (10, 100, 200, 200);
public Texture2D colourTexture;
public Renderer colouredCube;
private Rect textureRect = new Rect (10, 50, 100, 100);
bool opt = false;
public void ShowWindow() {
render = true;
}
public void HideWindow() {
render = false;
}
public void OnGUI() {
if (GUI.Button (new Rect (10, 20, 100, 20), "Show Window"))
opt = !opt;
ShowWindow ();
if (opt) {
if (GUI.Button (new Rect (10, 20, 100, 20), "Hide Window"))
HideWindow ();
if (render) {
windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window");
}
}
}
public void DoMyWindow(int windowID) {
}
}
}