0
IEnumerator GetFileRequest(List<String> urlList, Action<List<UnityWebRequest>> callback)
{
    List<UnityWebRequest> reqList = new List<UnityWebRequest>();
    for (int i = 0; i < urlList.Count; i++)
    {
        using (UnityWebRequest req = UnityWebRequest.Get(urlList[i]))
        {
            req.downloadHandler = new DownloadHandlerFile(GetFilePath(urlList[i]));
            reqList.Add(req);
        }
    }
        yield return reqList;

    callback(reqList);
}

I'm using this code, all files get downloaded, but they seem to be corrupted ( I guess it's not completely downloaded). How do I complete the download without files getting corrupted?

MrRobot9
  • 2,402
  • 4
  • 31
  • 68
  • Shouldn't you dispose at callee site ? Using `using` right away is probably the cause. – aybe Sep 01 '20 at 00:27
  • please see the linked duplicate. Main issue with your attempt: You never called [`SendWebRequest`](https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.SendWebRequest.html) so the request are created but never actually submitted. As aybe mentioned: You also are disposing the requests before your callback handles them, you have to either `.Dispose()` them in the callback or in a loop after invoking the callback instead – derHugo Sep 01 '20 at 06:45

0 Answers0