UnityWebRequest.isHttpError is deprecated
时间: 2024-01-18 16:03:54 浏览: 32
Yes, you are correct. The Unity `UnityWebRequest.isHttpError` property is deprecated starting from Unity version 2020.1. Instead, you should use the `UnityWebRequest.result` property to check for errors. Here's an example of how you can handle HTTP errors using the new approach:
```csharp
UnityWebRequest request = UnityWebRequest.Get("https://example.com/api/data");
yield return request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success)
{
Debug.LogError(request.error);
// Handle error gracefully
}
else
{
// Handle successful response
}
```
In the code snippet above, we check the `request.result` property instead of `isHttpError` to determine if there was an error during the request. If `request.result` is not equal to `UnityWebRequest.Result.Success`, we can access the error message using `request.error`.