public IEnumerator DownloadingFiles(List <UrlFilePath> urlFilePaths, ICancellationToken cancellationToken, OnDownloadCompleted onCompleted, OnDownloadProgressChanged onProgressChanged) { bool noError = true; for (int i = 0; i < urlFilePaths.Count; i++) { if (cancellationToken.Canceled) { noError = false; break; } int currentI = i; int currentCount = urlFilePaths.Count; UrlFilePath item = urlFilePaths[i]; yield return(GameLogicUpdateSystem.StartCoroutine(DownloadingFile(item.Url, item.FilePath, cancellationToken, (ne) => { if (!ne) { noError = ne; } }, (percents) => { int currentPercents = Mathf.RoundToInt((100 * currentI + percents) / (float)currentCount); onProgressChanged?.Invoke(currentPercents); }))); } onCompleted?.Invoke(noError); }
public void DownloadFileAsync(UrlFilePath urlFilePath, ICancellationToken cancellationToken, OnDownloadCompleted onCompleted, OnDownloadProgressChanged onProgressChanged) => DownloadFileAsync(urlFilePath.Url, urlFilePath.FilePath, cancellationToken, onCompleted, onProgressChanged);