The samples in the [manual][1] show using UnityWebRequest.isError method. Unfortunately (see the [docs][2] for that field) isError returns false when the web server returns an error such as 404 Not Found.
What would be a good way to determine if your web request succeeded in returning data that you can use? I'm thinking of something like this:
private bool IsFailedRequest(UnityWebRequest request)
{
return request.isError || (request.responseCode != (long)System.Net.HttpStatusCode.OK);
}
But I'm concerned that there may be other success status codes that I should be checking for. Also, although I'm getting 200 (HttpStatusCode.OK) back from a successful UnityWebRequest.Get, the result from a successful UnityWebRequest.GetAssetBundle call is returning 0 (not a status code). Is there a better way to check for success?
[1]: https://docs.unity3d.com/Manual/UnityWebRequest.html
[2]: https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest-isError.html
↧