I want to create a global array in order to listen for events
I have a coroutine that is invoked several times on my scene.
IEnumerator Save_assets(string file, int i, string name){
var filename = Path.GetFileName(file);
docPath = Application.streamingAssetsPath+"/files/";
var temp_name = docPath+filename;
downloaded_asset = false;
if(!Directory.Exists(docPath)){
Directory.CreateDirectory(docPath);
}
if (!System.IO.File.Exists(temp_name)){
WWW www = new WWW(file);
yield return www;
//Save the image
System.IO.File.WriteAllBytes(temp_name, www.bytes);
}
/* I really would like to have a sort of listener here doing
something like:
//pseudocode
while(global.file != true){ //while not done
yield return null;
}
*/
downloaded_asset = true;
finished = false;
tries = 0;
go = GameObject.Find(name);
go.gameObject.BroadcastMessage("paint_file", temp_name);
}
Once paint_file has been invoked the Update function on that very class is
constantly looking for a certain condition to happen, let's say it's "done
= true;"
void paint_file(file){
[...]//code
}
void Update () {
var done = true;//let's pretend there's no code here, just done = true
if(done){
Debug.Log("Finished: "+paint_file._filename);
}
}
I have no idea how to set this var global.file = done, any help would be
greatly appreciated
No comments:
Post a Comment