so im working on an app that has to get the location of one's phone and tell the weather.for now i did the script to find its location which works perfectly fine in the unity peview but while trying to build it i am getting several errors such as
the networking code looks as such:
and the "tara" class is this one:
pls help
CodePudding user response:
The way you are currently checking for errors is no longer correct with the latest version of the UnityWebRequest API. Follow this example instead:
using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
{
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
switch (webRequest.result)
{
case UnityWebRequest.Result.ConnectionError:
case UnityWebRequest.Result.DataProcessingError:
Debug.LogError("Error: " webRequest.error);
break;
case UnityWebRequest.Result.ProtocolError:
Debug.LogError("HTTP Error: " webRequest.error);
break;
case UnityWebRequest.Result.Success:
Debug.Log("Received: " webRequest.downloadHandler.text);
break;
}
}
Reference: https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.Get.html