Last active
December 22, 2015 16:29
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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