Answers for "egt request unity"

C#
2

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);
        }
    }
Posted by: Guest on December-31-2020
2

how to do a web request unity

IEnumerator SendRequest(string url)
    {
        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
            Debug.Log(request.downloadHandler.text);
        }
    }
Posted by: Guest on October-24-2020

C# Answers by Framework

Browse Popular Code Answers by Language