| usingNewtonsoft.Json; |
| usingSystem; |
| usingSystem.Collections; |
| usingSystem.Collections.Generic; |
| usingSystem.Globalization; |
| usingUnityEngine; |
| usingUnityEngine.UI; |
| |
| publicclassConnectWeather : MonoBehaviour { |
| RootObjectwthr; |
| publicTexttxtDegree; |
| publicTexttxtH; |
| publicTexttxtW; |
| publicTexttxtWfull; |
| publicTexttxtTime; |
| publicTexttxtTimeZone; |
| publicTexttxtWind; |
| // Use this for initialization |
| voidStart () { |
| GetWeather(); |
| |
| } |
| |
| // Update is called once per frame |
| voidUpdate () { |
| |
| } |
| |
| publicvoidGetWeather() |
| { |
| WWWFormform=newWWWForm(); |
| |
| |
| varwww=newWWW(ServerURL.Weather); |
| |
| StartCoroutine(wfrWeather(www)); |
| } |
| |
| IEnumeratorwfrWeather(WWWwww) |
| { |
| yieldreturnwww; |
| if (www.error==null) |
| { |
| Debug.Log("User Login :"+www.text); |
| |
| wthr=JsonConvert.DeserializeObject<RootObject>(www.text); |
| |
| txtDegree.text=wthr.current_observation.temp_c.ToString() +" C"; |
| txtH.text="H "+wthr.current_observation.relative_humidity.ToString() ; |
| txtW.text=wthr.current_observation.weather; |
| |
| txtWfull.text=wthr.current_observation.display_location.full; |
| |
| //Sat, 29 Apr 2017 08:34:24 + 0300 |
| |
| txtTime.text="Local Time : "+wthr.current_observation.local_time_rfc822.Substring(17, 5); |
| txtTimeZone.text="Time Zone : "+wthr.current_observation.local_tz_short; |
| txtWind.text="Wind : "+wthr.current_observation.wind_dir+""+ |
| wthr.current_observation.wind_kph+"kph"; |
| // GetNasaImege(Nasa); |
| print(www.text); |
| //LoadScene(); |
| } |
| else |
| { |
| Debug.Log("WWW Error: "+www.error); |
| Debug.Log("WWW Error: "+www.text); |
| //txt.text = www.error; |
| } |
| } |
| |
| } |
| |
| publicclassFeatures |
| { |
| publicstringconditions { get; set; } |
| } |
| |
| publicclassResponse |
| { |
| publicstringversion { get; set; } |
| publicstringtermsofService { get; set; } |
| publicFeaturesfeatures { get; set; } |
| } |
| |
| publicclassImage |
| { |
| publicstringurl { get; set; } |
| publicstringtitle { get; set; } |
| publicstringlink { get; set; } |
| } |
| |
| publicclassDisplayLocation |
| { |
| publicstringfull { get; set; } |
| publicstringcity { get; set; } |
| publicstringstate { get; set; } |
| publicstringstate_name { get; set; } |
| publicstringcountry { get; set; } |
| publicstringcountry_iso3166 { get; set; } |
| publicstringzip { get; set; } |
| publicstringmagic { get; set; } |
| publicstringwmo { get; set; } |
| publicstringlatitude { get; set; } |
| publicstringlongitude { get; set; } |
| publicstringelevation { get; set; } |
| } |
| |
| publicclassObservationLocation |
| { |
| publicstringfull { get; set; } |
| publicstringcity { get; set; } |
| publicstringstate { get; set; } |
| publicstringcountry { get; set; } |
| publicstringcountry_iso3166 { get; set; } |
| publicstringlatitude { get; set; } |
| publicstringlongitude { get; set; } |
| publicstringelevation { get; set; } |
| } |
| |
| publicclassEstimated |
| { |
| } |
| |
| publicclassCurrentObservation |
| { |
| publicImageimage { get; set; } |
| publicDisplayLocationdisplay_location { get; set; } |
| publicObservationLocationobservation_location { get; set; } |
| publicEstimatedestimated { get; set; } |
| publicstringstation_id { get; set; } |
| publicstringobservation_time { get; set; } |
| publicstringobservation_time_rfc822 { get; set; } |
| publicstringobservation_epoch { get; set; } |
| publicstringlocal_time_rfc822 { get; set; } |
| publicstringlocal_epoch { get; set; } |
| publicstringlocal_tz_short { get; set; } |
| publicstringlocal_tz_long { get; set; } |
| publicstringlocal_tz_offset { get; set; } |
| publicstringweather { get; set; } |
| publicstringtemperature_string { get; set; } |
| publicdoubletemp_f { get; set; } |
| publicdoubletemp_c { get; set; } |
| publicstringrelative_humidity { get; set; } |
| publicstringwind_string { get; set; } |
| publicstringwind_dir { get; set; } |
| publicstringwind_degrees { get; set; } |
| publicdoublewind_mph { get; set; } |
| publicstringwind_gust_mph { get; set; } |
| publicdoublewind_kph { get; set; } |
| publicstringwind_gust_kph { get; set; } |
| publicstringpressure_mb { get; set; } |
| publicstringpressure_in { get; set; } |
| publicstringpressure_trend { get; set; } |
| publicstringdewpoint_string { get; set; } |
| publicstringdewpoint_f { get; set; } |
| publicstringdewpoint_c { get; set; } |
| publicstringheat_index_string { get; set; } |
| publicstringheat_index_f { get; set; } |
| publicstringheat_index_c { get; set; } |
| publicstringwindchill_string { get; set; } |
| publicstringwindchill_f { get; set; } |
| publicstringwindchill_c { get; set; } |
| publicstringfeelslike_string { get; set; } |
| publicstringfeelslike_f { get; set; } |
| publicstringfeelslike_c { get; set; } |
| publicstringvisibility_mi { get; set; } |
| publicstringvisibility_km { get; set; } |
| publicstringsolarradiation { get; set; } |
| publicstringUV { get; set; } |
| publicstringprecip_1hr_string { get; set; } |
| publicstringprecip_1hr_in { get; set; } |
| publicstringprecip_1hr_metric { get; set; } |
| publicstringprecip_today_string { get; set; } |
| publicstringprecip_today_in { get; set; } |
| publicstringprecip_today_metric { get; set; } |
| publicstringicon { get; set; } |
| publicstringicon_url { get; set; } |
| publicstringforecast_url { get; set; } |
| publicstringhistory_url { get; set; } |
| publicstringob_url { get; set; } |
| publicstringnowcast { get; set; } |
| } |
| |
| publicclassRootObject |
| { |
| publicResponseresponse { get; set; } |
| publicCurrentObservationcurrent_observation { get; set; } |
| } |