public IEnumerator FinalizeDownloadRequest(UnityWebRequest request, DLCBundle bundle) { if (requiresUnpacking.Contains(request) && !(request.isHttpError || request.isNetworkError)) { // construct the parameters to decompress file DecompressZipfileParams p = new DecompressZipfileParams(bundle.path, bundle.category); // create a new thread so we dont block the main thread while we decompress Thread t = new Thread(DecompressZipfile); // start the work t.Start(p); // wait till the thread indicates it's ready yield return(new WaitUntil(() => p.isFinished)); // join the thread t.Join(); // remove the request from the requiresUnpacking list requiresUnpacking.Remove(request); // delete the zip file we downloaded earlier DeleteFile(bundle.path); } request.Dispose(); }
private void DecompressZipfile(object data) { DecompressZipfileParams p = (DecompressZipfileParams)data; string targetDir = Path.Combine(DLCLocalService.Instance.GetDLCPath(), p.bundleCategory); ZipFile.ExtractToDirectory(p.compressedFile, targetDir); p.isFinished = true; }