シーンで数回呼び出されるコルーチンがあります。
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);
}
paint_file が呼び出されると、まさにそのクラスの Update 関数が常に発生する特定の条件を探します。たとえば、「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);
}
}
この var global.file = done を設定する方法がわかりません。どんな助けでも大歓迎です