request.downloadHandler.text to streamreader code example
Example: egt request unity
// kinda like the other snippets, but with a callback:
IEnumerator SendRequest(string url, System.Action<string> callback) {
UnityWebRequest request = UnityWebRequest.Get(url);
yield return request.SendWebRequest();
if (request.isNetworkError || request.isHttpError)
{
Debug.LogError(string.Format("Error: {0}",request.error));
}
else
{
// Response can be accessed through: request.downloadHandler.text
callback(request.downloadhandler.text);
}
}