Unity的UnityWebRequest如果设置了timeout,在超时后会有一个Curl error 28的报错,很是讨厌,强迫症患者可以用下面的办法过滤掉。
async private void Start()
{
UnityWebRequest unityWeb;
unityWeb = new UnityWebRequest(url, "Get");
unityWeb.downloadHandler = new DownloadHandlerBuffer();
//unityWeb.timeout = 3;
var taskget = unityWeb.SendWebRequest();
await Task.Delay(3000);
if (unityWeb.result != UnityWebRequest.Result.Success)
{
Debug.LogWarning("Http获取远程文件失败: " + unityWeb.result.ToString() + " , Url:" + url);
loaderror = true;
}
unityWeb.Dispose();
}
核心思想就是不用timeout,直接3秒后就判断就是下载到了。