How to capture Curl error 28 in Unity

If Unity's UnityWebRequest is set with a timeout, there will be a Curl error 28 error after the timeout , which is very annoying. Patients with obsessive-compulsive disorder can filter it out by the following method.

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();
}

The core idea is not to use timeout, and it will be judged that it has been downloaded after 3 seconds.

おすすめ

転載: blog.csdn.net/thinbug/article/details/129187900