📜  如何统一进行 Web 请求 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:42.596000             🧑  作者: Mango

代码示例1
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);
        }
    }