예제 #1
0
    private IEnumerator GetCoordinates()
    {
        var www = new UnityWebRequest("http://ip-api.com/json/" + IPAddress)
        {
            downloadHandler = new DownloadHandlerBuffer()
        };

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            //error
            yield break;
        }

        Info      = JsonUtility.FromJson <LocationInfo>(www.downloadHandler.text);
        latitude  = Info.lat;
        longitude = Info.lon;
        weatherData.Begin();
    }