IEnumerator GetRequest(string uri)
    {
        UnityWebRequest uwr = UnityWebRequest.Get(uri);

        yield return(uwr.SendWebRequest());

        if (uwr.isNetworkError)
        {
            Debug.Log("Error While Sending: " + uwr.error);
        }
        else
        {
            Debug.Log("Received: " + uwr.downloadHandler.text);
            string json = uwr.downloadHandler.text;
            allWeatherStats = JsonUtility.FromJson <AllWeatherStats>(json);
        }
    }
示例#2
0
    IEnumerator GetRequest(string uri)
    {
        UnityWebRequest uwr = UnityWebRequest.Get(uri);

        yield return(uwr.SendWebRequest());

        if (uwr.isNetworkError)
        {
            Debug.Log("Error While Sending: " + uwr.error);
        }
        else
        {
            Debug.Log("Received: " + uwr.downloadHandler.text);
            string json = uwr.downloadHandler.text;
            allWeatherStats = JsonUtility.FromJson <AllWeatherStats>(json);
            UIManager.Instance.WeatherInfo.text = "The weathercast for today is : " + allWeatherStats.weather[0].main + " with " + allWeatherStats.weather[0].description + "if you use this feature you won't need to add more water to the plants for this day";
        }
    }