How to invisible first window on click .

I have a window called “red window” on scene1.
When i click on the hello world button it should displays another window called green window and the first window should invisible. How it possible.

35842-unityimage.jpg

   using UnityEngine;
   using System.Collections;

    public class window : MonoBehaviour {
private bool render = false;
	public Rect windowRect0 = new Rect(20, 20, 120, 50);
	public Rect windowRect1 = new Rect(20, 100, 120, 50);
	void OnGUI() {
		GUI.color = Color.red;
		windowRect0 = GUI.Window(0, windowRect0, DoMyWindow, "Red Window");
		GUI.color = Color.green;
	   windowRect1 = GUI.Window(1, windowRect1, DoMyWindow1, "Green Window");
	}
	void DoMyWindow(int windowID) {
		if (GUI.Button (new Rect (10, 20, 100, 20), "Hello World")) {
			}
	

		  //GUI.DragWindow(new Rect(0, 0, 10000, 10000));
	}
void DoMyWindow1(int windowID) {
	if (GUI.Button(new Rect(10, 20, 100, 20), "Hello World"))
		print("Got a click in window with color2222222222 " + GUI.color);
	//GUI.DragWindow(new Rect(0, 0, 10000, 10000));
}

}

Hello @Deepschalappatta,

You can use bool to show and hide window(any gui object). I make here toggle window. Check it out and you get basic idea.

private bool render = false;
public Rect windowRect0 = new Rect(20, 20, 120, 50);
public Rect windowRect1 = new Rect(20, 100, 120, 50);

bool IsRedWindowOpen = true;

void OnGUI() {
	if(IsRedWindowOpen)
	{
		GUI.color = Color.red;
		windowRect0 = GUI.Window(0, windowRect0, DoMyWindow, "Red Window");
	}
	else
	{
		GUI.color = Color.green;
		windowRect1 = GUI.Window(1, windowRect1, DoMyWindow1, "Green Window");
	}
}
void DoMyWindow(int windowID) {
	if (GUI.Button (new Rect (10, 20, 100, 20), "Hello World")) {
		IsRedWindowOpen = false;
	}
	
	
	
	//GUI.DragWindow(new Rect(0, 0, 10000, 10000));
}
void DoMyWindow1(int windowID) {
	if (GUI.Button(new Rect(10, 20, 100, 20), "Hello World"))
		IsRedWindowOpen = true;
		print("Got a click in window with color2222222222 " + GUI.color);
	//GUI.DragWindow(new Rect(0, 0, 10000, 10000));
}