Home > Blockchain >  Android App that uses unitywebrequest does not build although it runs in unity
Android App that uses unitywebrequest does not build although it runs in unity

Time:11-20

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 asenter image description here

the networking code looks as such: enter image description here

and the "tara" class is this one: enter image description here

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

  • Related