Ejemplo n.º 1
0
    IEnumerator GetText()
    {
        UnityWebRequest www = UnityWebRequest.Get(url);

        yield return(www.SendWebRequest());

        if (www.isNetworkError)
        {
            Debug.Log(www.error);
        }
        else
        {
            string    result         = www.downloadHandler.text;
            _Particle fields         = JsonUtility.FromJson <_Particle>(result);
            string    currentWeather = fields.list[0].weather[0].main;
            if (currentWeather == "Clouds")
            {
                weatherState = 1;
            }
            else if (currentWeather == "Rain")
            {
                weatherState = 2;
            }
            else if (currentWeather == "Clear")
            {
                weatherState = 3;
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator WaitForRequest(WWW www)
    {
        yield return(www);

        // check for errors
        if (www.error == null)
        {
            string work = www.text;

            Debug.Log("hello");
            MyError obj = JsonConvert.DeserializeObject <MyError>(work);
            Debug.Log(obj.feeds);
            foreach (var employee in obj.feeds)
            {
                JSON_Time        = employee.created_at;
                JSON_Temperature = employee.field1;
                Debug.Log(employee.created_at);
                Debug.Log(employee.field1);
            }
            _Particle soil = JsonUtility.FromJson <_Particle>(work);
            JSON_Name = soil.channel.name;
            //JSON_Country = fields.location.country;
            //JSON_Weather = fields.current.condition.text;
            //JSON_Temperature = fields.current.temp_c;
            //temperature = float.Parse (JSON_Temperature);
            //Debug.Log (JSON_Name);
            //Debug.Log (JSON_Country);
            //Debug.Log (JSON_Weather);
            //Debug.Log (JSON_Temperature);
        }
        else
        {
        }
    }
Ejemplo n.º 3
0
    IEnumerator WaitForRequest(WWW www)                                 //Obtain Variables from the Photon Cloud using JSON
    {
        yield return(www);

        // check for errors
        if (www.error == null)
        {
            string work = www.data;

            _Particle fields   = JsonUtility.FromJson <_Particle>(work);
            string    jsonRate = fields.result;

            ParticleVariable = float.Parse(jsonRate);
            //Debug.Log (ParticleVariable);			//Debug to console
            ForceInput = ParticleVariable;
        }
        else
        {
        }
    }
Ejemplo n.º 4
0
    IEnumerator WaitForRequest(WWW www)
    {
        yield return(www);

        // check for errors
        if (www.error == null)
        {
            string work = www.data;

            _Particle fields   = JsonUtility.FromJson <_Particle>(work);
            string    jsonRate = fields.result;

            tempHR         = float.Parse(jsonRate);
            heartrateInput = Mathf.FloorToInt(tempHR);
            Debug.Log(heartrateInput);
        }
        else
        {
        }
    }
    IEnumerator WaitForRequest(WWW www)
    {
        yield return(www);

        // check for errors
        if (www.error == null)
        {
            string work = www.text;

            _Particle fields   = JsonUtility.FromJson <_Particle>(work);
            string    jsonRate = fields.result;

            temp = double.Parse(jsonRate);
            //TemperatureInput = Mathf.FloorToInt(temp);
            TemperatureInput = temp;
            //Debug.Log (TemperatureInput);
        }
        else
        {
        }
    }
Ejemplo n.º 6
0
    IEnumerator WaitForRequest(WWW www)             //Obtain Variables from the Photon Cloud using JSON
    {
        yield return(www);

        // check for errors
        if (www.error == null)
        {
            string work = www.text;

            _Particle fields   = JsonUtility.FromJson <_Particle>(work);
            string    jsonRate = fields.completed;

            // ParticleVariable = float.Parse(jsonRate);
            Debug.Log(jsonRate);           //Debug to console
            //ForceInput = ParticleVariable;

            fields.title = "my text";
            string newfield = JsonUtility.ToJson(fields);
            Debug.Log(newfield);
        }
        else
        {
        }
    }
    IEnumerator WaitForRequest(WWW www)
    {
        yield return(www);

        // check for errors
        if (www.error == null)
        {
            string work = www.text;

            _Particle fields = JsonUtility.FromJson <_Particle>(work);
            JSON_Name        = fields.location.name;
            JSON_Country     = fields.location.country;
            JSON_Weather     = fields.current.condition.text;
            JSON_Temperature = fields.current.temp_c;
            temperature      = float.Parse(JSON_Temperature);
            Debug.Log(JSON_Name);
            Debug.Log(JSON_Country);
            Debug.Log(JSON_Weather);
            Debug.Log(JSON_Temperature);
        }
        else
        {
        }
    }