I have some code that allows me to grab all my image paths in my Android device. Then, I want to load those images into texture using www classs, such as:
public void SetImage()
{
List<string> galleryImages = GetAllGalleryImagePaths();
DebugText.text = galleryImages.Count.ToString() + " images found";
DisplayPanel.SetActive(true);
ControlPanel.SetActive(false);
for (int i = 0; i < galleryImages.count; i++)
{
WWW www = new WWW(galleryImages[i]);
Texture2D t = new Texture2D(2, 2);
http://ift.tt/22AX7Vf;
GameObject imgObj = Instantiate(Resources.Load("GalleryImage")) as GameObject;
imgObj.GetComponent<RawImage>().texture = t;
imgObj.transform.SetParent(contentHolder.transform);
}
}
However, if I call http://ift.tt/22AX7Vf and loop too many times, the app will just jump out to the home screen. (a few times, like 20 times, is fine)
Anyone knows the problem and how to fix it?
Aucun commentaire:
Enregistrer un commentaire