Skip to content

Instantly share code, notes, and snippets.

@dbuck
Last active December 22, 2015 16:29
Show Gist options
  • Select an option

  • Save dbuck/6499954 to your computer and use it in GitHub Desktop.

Select an option

Save dbuck/6499954 to your computer and use it in GitHub Desktop.
Unity3d - wait for a list of WWW's to finish downloading, checking in intervals and reporting progress to console for large files.
IEnumerator _WaitForAllDownloadsToFinish(List<WWW> wwws, float checkInterval = 1f, string helperName = "")
{
yield return new WaitForEndOfFrame(); //start checking next frame, to let the downloads start
while (true)
{
var done = true;
foreach (var r in wwws)
{
done = done & r.isDone;
if (r.error != null)
{
Debug.Log(r.error);
}
if (!r.isDone && SpamLogs)
{
Debug.Log("Downloading: " + r.progress + " " + r.url);
}
}
yield return new WaitForSeconds(checkInterval);
if (done)
break;
}
Debug.Log(Helpers.TimeStamp() + helperName + " cache is up to date");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment