I am trying to load an image from a URL http://openweathermap.org/img/wn/{code}@2x.png. But I get cast error on loading
IEnumerator GetWeatherImage(string imageCode)
{
Debug.Log($"Code received {imageCode}");
UnityWebRequest www = UnityWebRequest.Get($"openweathermap.org/img/wn/{imageCode}@2x.png");
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Texture weatherTexture = DownloadHandlerTexture.GetContent(www); // cast error
}
}
I tried pasting the URL in my browser and it works fine
Also followed the docs
↧