public void CheckSnowStatus(WeatherInfo weatherObj) { bool snowing = weatherObj.weather[0].main.Equals("Snow"); print(weatherObj.weather[0].main); if (snowing) { snowSystem.SetActive(true); } else { snowSystem.SetActive(false); } }
IEnumerator GetWeather(Action <WeatherInfo> onSuccess) { using (UnityWebRequest req = UnityWebRequest.Get($"http://api.openweathermap.org/data/2.5/weather?id={cityId}&APPID={API_KEY}")) { yield return(req.SendWebRequest()); // the point where the method will be resumed from the next frame while (!req.isDone) // makes sure that the response arrived before continuing with any other { yield return(null); } byte[] result = req.downloadHandler.data; string weatherJSON = System.Text.Encoding.Default.GetString(result); WeatherInfo info = JsonUtility.FromJson <WeatherInfo>(weatherJSON); onSuccess(info); } }