I have a IEnumerator function that download a image from a server, on script not attached to prefabs, it works, but on script attached to prefabs, it doesnt work.
By doesnt work i want to say that the www.SendWebRequest() never returns, i've waited for almost 10 minutes and its doesnt returns, the image has about 200kb, so the problem isn't the image size.
I already checked if the url is correct, tried to change the image, tried to re-write the function but nothing works, this is my function:
public void Set(string NomeIcone, string NomeAnalise, string idzinho, string descricaozinha, string NomeCapa)
{
Name.text = NomeAnalise;
ID = idzinho;
Descricao = descricaozinha;
Capa = NomeCapa;
StartCoroutine(LoadLogo(NomeIcone));
}
public IEnumerator LoadLogo(string nomeArquivo)
{
string url = PathIcone + nomeArquivo;
print(url);
using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(url))
{
yield return www.SendWebRequest();
if (www.error == null)
{
Texture2D tex = new Texture2D(1, 1);
tex = DownloadHandlerTexture.GetContent(www);
Icon.texture = tex;
RawImage Foto = Icon.GetComponentInChildren<RawImage>();
Foto.SetNativeSize();
float altura = 100 * Foto.rectTransform.rect.height / Foto.rectTransform.rect.width;
Foto.rectTransform.sizeDelta = new Vector2(100, altura);
}
}
}
My prefab setup in the inspector
As you can see, my "IconeSimbolo" is a RawImage in the prefab which this script is attached
I expect to my "IconeSimbolo" texture change to the image on the server, but it never changes.
I have this same code on another script with the same setup on the inspector, on this another prefab everything works fine, but in this one it doesnt