I am creating a unity app that displays questions in pictogram format. When loading the images using WiFi (first they are downloaded and then displayed from local storage) it works perfectly, however as soon as I start using my phone data this no longer works (All images are downloading on data with a 200 response). Has anyone else encountered this problem?
I have tried only loading from local storage whether there is an internet connection or not but nothing seems to work. I have entered the image URLs into my phone browser to make sure my provider wasn´t blocking them also no problem. this is the method to formulate the questions
` public void FormularPreguntas(Respuesta[] res)
{
Debug.Log("Starting FormularPreguntas method");
bool dosResp = false;
int numRespuestas = res.Length;
Debug.Log($"Number of responses: {numRespuestas}");
if (numRespuestas == 2)
dosResp = true;
for (int i = 0; i < numRespuestas; i++)
{
GameObject resps;
if (dosResp)
{
resps = panel.transform.GetChild(i + 1).gameObject;
resps.SetActive(true);
Debug.Log($"Activated response panel {i + 1} for 2 responses");
}
else
{
resps = panel.transform.GetChild(i + 3).gameObject;
resps.SetActive(true);
Debug.Log($"Activated response panel {i + 3} for multiple responses");
}
if (!quiereImagenes)
{
GameObject respuestaTexto = resps.transform.GetChild(0).gameObject;
respuestaTexto.SetActive(true);
Text textResp = respuestaTexto.GetComponent<Text>();
textResp.text = res[i].descripcion;
Debug.Log($"Set text for response {i}: {res[i].descripcion}");
}
else
{
BDActu BDActu = FindObjectOfType<BDActu>();
GameObject respuestaSprite = resps.transform.GetChild(1).gameObject;
respuestaSprite.SetActive(true);
if (BDActu != null && BDActu.spritesRespuestas.Length > res[i].idRespuesta - 1)
{
SpriteRenderer spriteResp = respuestaSprite.GetComponent<SpriteRenderer>();
spriteResp.sprite = BDActu.spritesRespuestas[res[i].idRespuesta - 1];
Debug.Log($"Set sprite for response {i}: {BDActu.spritesRespuestas[res[i].idRespuesta - 1]}");
}
else
{
Debug.LogError($"Sprite for response {res[i].idRespuesta - 1} not found in BDActu");
}
}
if (QuiereAudio())
{
Debug.Log($"Adding audio for response {i}");
}
if (res[i].esCorrecta)
{
idResp = i;
Debug.Log($"Correct response identified: {i}");
}
}
}`
this is bdACTU mehtod to loadSprites
`public IEnumerator CargarSprites(string nombre, int i, int dif)
{
string cosa = nombre + ".png";
string path = Path.Combine(Application.persistentDataPath, "Pictogramas");
path = Path.Combine(path, cosa);
float num = 0.3f * i;
yield return new WaitForSeconds(num);
byte[] resulta = File.ReadAllBytes(path);
Texture2D texture = new Texture2D(2, 2);
texture.LoadImage(resulta);
if (dif == 0)
{
Debug.Log("Creado sprite preguntas de "+nombre);
spritesPreguntas[i] = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 6.0f);
}
else if (dif == 1)
{
Debug.Log("Creado sprite respuestas de "+nombre);
spritesRespuestas[i] = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 8f);
}
else if (dif == 2)
{
Debug.Log("Creado sprite datos de "+nombre);
spritesDatos[i] = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 7.0f);
}
}`