Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ForecastController : MonoBehaviour
- {
- public GameObject helloworld;
- IEnumerator AdjustSkyToWeather()
- {
- while (true)
- {
- string weatherUrl = "http://api.openweathermap.org/data/2.5/forecast?zip=2000,au&APPID=d38ee94695788506fb6b2be25a1b7303";
- WWW weatherWWW = new WWW(weatherUrl);
- yield return weatherWWW;
- JSONObject tempData = new JSONObject(weatherWWW.text);
- Debug.Log(tempData["list"][0]["main"]["humidity"]);
- helloworld.GetComponent<TextMesh>().text = tempData["list"][0]["main"]["humidity"].ToString();
- yield return new WaitForSeconds(60);
- }
- }
- void Start()
- {
- StartCoroutine(AdjustSkyToWeather());
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class iotAPIScript : MonoBehaviour
- {
- public GameObject iotText;
- IEnumerator GetIoTData()
- {
- while (true)
- {
- string iotDBURL = "https://iotar01-ad83.restdb.io/rest/test-collection/5be9faed3dca561f00004ab7";
- WWW iotDB = new WWW(iotDBURL);
- yield return iotDB;
- JSONObject tempData = new JSONObject(iotDB.text);
- Debug.Log(tempData["iottest03"]);
- iotText.GetComponent<TextMesh>().text = tempData["iottest03"].ToString();
- yield return new WaitForSeconds(60);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement