2

我正在使用 UnityWebRequest 从我的服务器下载资产包。有时以下代码会返回不同的异常,例如Failed to receive data, Cannot resolve destination host, Cannot connect to destination host,Unknown ErrorRequest timeout

这是我的代码的一部分。

UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url,(uint)data.version,0);

                    Debug.Log ("Downloading " + url);
                    
                    yield return www.SendWebRequest();
                    AssetBundle bundle = null;
                    if(www.isNetworkError || www.isHttpError) {
                        Debug.Log(www.isNetworkError);
                        Debug.Log(www.isHttpError);
                        Debug.Log(www.error);

                        if (ARSceneManager.Instance != null)
                            data.downloadAssetBundlesCompleted?.Invoke(null);
                    } else {
                        bundle = DownloadHandlerAssetBundle.GetContent(www);
                    }

                    if (!string.IsNullOrEmpty(www.error)) {

                        throw new Exception("WWW download: " + url + ", " + www.error);
                    }

所以我得到了不同网址的错误,在某些情况下。

PS下一次使用相同的URL,它也可以在浏览器中使用。所以我认为网址没有问题。

谢谢。

4

0 回答 0