loading problem

I have a script that creates 2 GUI buttons (one LOAD and the other New Game)…how can i get the file to load ? my problem is that im calling a “function LoadXML()” inside another function “OnGUI” butI dont know how to make the function LoadXML() work once activated …

the code is:

var shownewgame : boolean = false;
var showcontinue : boolean = false;
var levelToLoad : String;
var soundhover : AudioClip;
var beep : AudioClip;
var QuitButton : boolean = false;

function OnMouseEnter(){
audio.PlayOneShot(soundhover);
}
function OnMouseUp(){
animation.CrossFade("PlayButtonAnimation");
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.1);
if(QuitButton){
Application.Quit();
}
shownewgame = true;
showcontinue = true;
}  

function Update(){}

function OnGUI(){
if(shownewgame == true){
    if(GUI.Button(Rect(0,40,200,30),"New Game")){
       Application.LoadLevel(levelToLoad); //Code for new game button
    }
}
if(showcontinue == true){
    if(GUI.Button(Rect(0,80,200,30),"Continue")){
        
		//Code for continue button
		function LoadXML()
{
   //StreamReader r = File.OpenText(_FileLocation+"\\"+ _FileName);
   var r : StreamReader = File.OpenText(_FileLocation+"/"+ _FileName);
   var _info : String = r.ReadToEnd();
   r.Close();
   _data=_info;
   Debug.Log("File Read");
}//Code for continue button
    }
}
}


@script RequireComponent(AudioSource)

First, don’t put the word ‘function’ here:

function LoadXML()

You put that whole function definition elsewhere outside OnGUI, and call it just LoadXML().

Second, I hope that’s a coroutine or launches a thread or something, because if it blocks, it’s going to mess with your GUI experience.