How To Make GUI Buttons Load/Quit

I’m using This Script.

var doWindow2 = true;

var mySkin : GUISkin;
var bgImage : Texture;

private var windowRect2 = Rect (0, 20, 350, 500);

private var scrollPosition0 : Vector2;
private var scrollPosition1 : Vector2;
private var HorSliderValue = 0.5;
private var VertSliderValue = 0.5;
private var Toggle0 = false;
private var Toggle1 = false;
private var Toggle2 = false;

//bringing it all together
function DoMyWindow2 (windowID : int) 
{
		GUILayout.Space(8);
		GUILayout.BeginVertical();
		GUILayout.Label("Welcome To Project Infinite");	
		
		GUILayout.Label ("Information.", "HeaderText");
		GUILayout.Label ("Project Infinite Is A One Man Team Attempting The Impossible. Enjoy!", "PlainText");
		GUILayout.Space(8);		
		
		GUILayout.Label ("Are You Ready?", "HeaderText");
        GUILayout.Label ("This Is Just A Test..", "PlainText");
	
		GUILayout.Space(190);
		GUILayout.Label ("Play Or Quit?", "HeaderText");
        GUILayout.BeginHorizontal();
        GUILayout.Button("Play.");        
        GUILayout.Button("Quit.");
        GUILayout.EndHorizontal();
		
        GUILayout.EndVertical();

}

function OnGUI ()
{
GUI.skin = mySkin;

GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height), bgImage);  

if (doWindow2)
	windowRect2 = GUI.Window (2, windowRect2, DoMyWindow2, "");
	//now adjust to the group. (0,0) is the topleft corner of the group.
	GUI.BeginGroup (Rect (0,0,100,100));
	// End the group we started above. This is very important to remember!
	GUI.EndGroup ();
}

How do i make it so when i click Play it will Application.LoadLevel(1)
and when i click quit it will do Application.Quit

I thought it would be.

if (GUILayout.Button ("Play.")) {
    Application.LoadLevel(1);
}

if (GUILayout.Button ("Quit.")) {
    Application.Quit;
}

But these peices of codes create new buttons instead of activation the already exsisting buttons able to do on click.

You are doing it wrong…

Simply inside your DoMyWindow2 function when you declare the buttons do the if statements:

function DoMyWindow2 (windowID : int) 
{
       GUILayout.Space(8);
       GUILayout.BeginVertical();
       GUILayout.Label("Welcome To Project Infinite");   

       GUILayout.Label ("Information.", "HeaderText");
       GUILayout.Label ("Project Infinite Is A One Man Team Attempting The Impossible. Enjoy!", "PlainText");
       GUILayout.Space(8);     

       GUILayout.Label ("Are You Ready?", "HeaderText");
        GUILayout.Label ("This Is Just A Test..", "PlainText");

       GUILayout.Space(190);
       GUILayout.Label ("Play Or Quit?", "HeaderText");
        GUILayout.BeginHorizontal();
        if(GUILayout.Button("Play."))
        {
           Application.LoadLevel(1);
        }
    
        if(GUILayout.Button("Quit."))
        {
            Application.Quit();
         }
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();

}