using System.Net;
4. Create DownloadZipFile Method.
Now method will look like..
public void DownloadZipFile (string zipURL, string filePath, string fileName)
{
WebClient client = new WebClient();
client.DownloadProgressChanged += Client_DownloadProgressChanged;
client.DownloadFileCompleted += SuccessResponse;
client.DownloadFileAsync(new System.Uri(zipURL), filePath + fileName);
}
5. Create assigned local methods
void Client_DownloadProgressChanged (object sender, DownloadProgressChangedEventArgs e)
{
if (e.ProgressPercentage >= 100)
{
// Download Complete
Debug.Log("Download Complete");
}
else
{
// Download In Progress
Debug.Log("Download Progress = " + e.ProgressPercentage + "%");
// You can use this method to show download progress
}
}
void SuccessResponse (object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if (e.Error == null)
{
Debug.Log("End of Download");
}
else
Debug.Log("SuccessResponse ---- Error --- \n " + e.Error);
}
6. Call DownloadZipFile method.
You need to pass your zip file url, file path and file name where you want to save this.
7. And done you will get your file downloaded.
I hope you will find this blogpost very useful while downloading additional data to your game with zipfile.
Let me know in the comment section below if you have any questions regarding this post or any other topic of Unity, I will try to reply ASAP.
Wonderful facts. Many thanks!