Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class ForecastController : MonoBehaviour
  7. {
  8. public GameObject helloworld;
  9. IEnumerator AdjustSkyToWeather()
  10. {
  11. while (true)
  12. {
  13. string weatherUrl = "http://api.openweathermap.org/data/2.5/forecast?zip=2000,au&APPID=d38ee94695788506fb6b2be25a1b7303";
  14.  
  15. WWW weatherWWW = new WWW(weatherUrl);
  16. yield return weatherWWW;
  17.  
  18. JSONObject tempData = new JSONObject(weatherWWW.text);
  19.  
  20. Debug.Log(tempData["list"][0]["main"]["humidity"]);
  21. helloworld.GetComponent<TextMesh>().text = tempData["list"][0]["main"]["humidity"].ToString();
  22.  
  23.  
  24. yield return new WaitForSeconds(60);
  25. }
  26. }
  27.  
  28. void Start()
  29. {
  30. StartCoroutine(AdjustSkyToWeather());
  31. }
  32. }
  33.  
  34. using System.Collections;
  35. using System.Collections.Generic;
  36. using UnityEngine;
  37. using UnityEngine.UI;
  38.  
  39. public class iotAPIScript : MonoBehaviour
  40. {
  41. public GameObject iotText;
  42. IEnumerator GetIoTData()
  43. {
  44. while (true)
  45. {
  46. string iotDBURL = "https://iotar01-ad83.restdb.io/rest/test-collection/5be9faed3dca561f00004ab7";
  47.  
  48. WWW iotDB = new WWW(iotDBURL);
  49. yield return iotDB;
  50.  
  51. JSONObject tempData = new JSONObject(iotDB.text);
  52.  
  53. Debug.Log(tempData["iottest03"]);
  54. iotText.GetComponent<TextMesh>().text = tempData["iottest03"].ToString();
  55.  
  56.  
  57. yield return new WaitForSeconds(60);
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement