1、Unity下载Zip压缩文件主要使用UnityWebRequest类。
可以参考以下方法:
webRequest = UnityWebRequest.Get(Path1); //压缩文件路径
webRequest.timeout = 60;
webRequest.downloadHandler = new DownloadHandlerBuffer();
long fileSize = GetLocalFileSize(Path2); //存贮路径
webRequest.SetRequestHeader("Range", "bytes=" + fileSize + "-");
webRequest.SendWebRequest();
while (!webRequest.isDone)
{
float progress = Mathf.Clamp01(webRequest.downloadProgress);
progressBar.fillAmount = progress;
progressText.text = string.Format("{0}%", Mathf.RoundToInt(progress * 100f));
yield return null;
}
if (webRequest.isNetworkError || webRequest.isHttpError)
{
progressObj.SetActive(false);
}
else
{
byte[] downloadedData = webRequest.downloadHandler.data;
File.WriteAllBy

本文详细讲解了在Unity中通过UnityWebRequest实现下载Zip文件并使用ZipFile.OpenRead进行解压的过程,涉及网络请求和文件操作技巧。
最低0.47元/天 解锁文章
1889

被折叠的 条评论
为什么被折叠?



