How to upload 60 remote images to Unity 5?

Asked

Viewed 59 times

1

I’m trying to upload 60 remote images from a JSON file, such as textures from a prefab, in three steps of 20 images. However, I can only upload 15.

My code below.

public IEnumerator SetGallery (List<string> Thumbnails,GameObject[] Photos)
{
    int cont = 0;
    string aux = "";
    /*while (!Caching.ready)
        yield return null;*/

    foreach (GameObject image in Photos) {
            if (cont < sizePerGallery) {
                aux = Thumbnails [cont];
                WWW www = new WWW (aux);
                yield return new WaitForSeconds(.5f);
                Renderer renderer = GetComponent<Renderer> ();
                renderer.material.mainTexture = www.texture;
                image.GetComponent<Renderer> ().material.mainTexture =  www.texture;
                www.LoadImageIntoTexture(image.GetComponent<Renderer> ().material.mainTexture as Texture2D);
                DestroyImmediate (www.texture);
                www.Dispose();
                System.GC.Collect ();
                cont++;
            }
    }
}

And I always have errors in the download.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.