当前位置:网站首页>Unity downloads files through the server address

Unity downloads files through the server address

2022-07-07 10:49:00 HCC2017

 public IEnumerator DownLoadToLocal(string downloadingUrl)
        {

           /// Get download information

           UnityWebRequest header = UnityWebRequest.Head(downloadingUrl);
            yield return header.SendWebRequest();
            if (!header.isHttpError && !header.isNetworkError)
            {
                Debug.Log(ulong.Parse(header.GetResponseHeader("Content-Length")));
            }

          /
            // Send download request
            webRequest = UnityWebRequest.Get(downloadingUrl);

           // Set timeout , if webRequest.SendWebRequest() Connection timeout will return , And isNetworkError by true
            webRequest.timeout = 30;
            yield return webRequest.SendWebRequest();

            if (webRequest.isNetworkError)
            {
                Debug.Log("Download Error:" + webRequest.error);
            }
         

原网站

版权声明
本文为[HCC2017]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130622491916.html