【发布时间】:2016-10-02 19:12:42
【问题描述】:
我有一些代码可以让我在我的 Android 设备中获取所有图像路径。然后,我想使用 www 类将这些图像加载到纹理中,例如:
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);
www.LoadImageIntoTexture(t);
GameObject imgObj = Instantiate(Resources.Load("GalleryImage")) as GameObject;
imgObj.GetComponent<RawImage>().texture = t;
imgObj.transform.SetParent(contentHolder.transform);
}
}
但是,如果我调用 www.LoadImageIntoTexture(t) 并循环太多次,应用程序只会跳到主屏幕。 (几次,比如20次就可以了)
有谁知道这个问题以及如何解决它?
【问题讨论】:
标签: android image web unity3d textures