I'm using UnityWebRequest to download asset bundles from my server. Sometimes the following code returns different exceptions such as Failed to receive data , Cannot resolve destination host, Cannot connect to destination host, Unknown Error, Request timeout and so on.
Here is the part of my code.
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);
}
So I get the errors for different urls and in some cases.
P.S. the same URL works for the next time, also it works in browser too. So I don't think there are issues with urls.
Thanks.
↧