public void CheckLocation(IPLocationInfo locationInfo) { string city = locationInfo.location.city; UpdateLocationLabel(city); StartCoroutine(GetWeatherByID(CheckWeatherStatus, API_URL_CITY_NAME, city)); }
IEnumerator GetLocationOfPlayer(Action <IPLocationInfo> onSuccess) { string ipv6 = IPManager.GetIP(ADDRESSFAM.IPv6); using (UnityWebRequest req = UnityWebRequest.Get(string.Format("https://geo.ipify.org/api/v1?apiKey=at_PsOE0ZNe1iwY5izVDMaUXPNT1rkVQ&ipAddress=", ipv6))) { yield return(req.SendWebRequest()); while (!req.isDone) { yield return(null); } byte[] result = req.downloadHandler.data; string locationJSON = System.Text.Encoding.Default.GetString(result); //Debug.Log(locationJSON); IPLocationInfo info = JsonUtility.FromJson <IPLocationInfo>(locationJSON); onSuccess(info); } }