A big problem with Button, Please Help

Hello

I make this script to call an application when the plyer click the button. the script works fine that what i'm thinking first but the problem is when a click the button, the application start open in many time,

alt text

this is the script that i use

unction OnGUI () {

    if (buttonOn ==true) {

            if (GUI.Button (Rect (450, 500, 400, 120), "Question1")) {
                    windowOn = true;
            }

            if (windowOn == true) {
                    System.Diagnostics.Process.Start(Application.dataPath + "/TEKLILA.exe");

            }
    }  

is there any solution to make my application open one time when i click the button. THanks for any help

Unless you turn buttonOn false after the user clicks the button once, then you will continue to open the application again and again. So he user clicks the button once then windowOn becomes true and every time OnGUI is called, you will open the application again.

I might do something like:

var appOpen = false;

function OnGUI () {

     if (buttonOn) {

         if (GUI.Button (Rect (450, 500, 400, 120), "Question1")) {
             if(!appOpen) {
                  appOpen = true;
                  System.Diagnostics.Process.Start(Application.dataPath + "/TEKLILA.exe");

                  //MakeButtonAvailable(10); //Will let the user click the
                  //button again in 10 seconds.

             }
          }
      }
}  

/*
function MakeButtonAvailable (seconds : int) {
     yield WaitForSeconds(seconds);
     appOpen = false;
}
*/

This way, when the user hits the button, the app opens, then the button won't open up any more applications. You could easily add a yield in another function which I demonstrated in parenthesis to delay the user clicking the button again for x seconds.

Thanks Man that work Fine. you are the best