I’m making a daydream app that needs to load thumbnails of images found on the device. I need them to be displayed in the UI so I tried creating sprites and Texture2Ds using WWW and coroutines but it ran really slowly and crashed if I loaded more than 30 images. What is the correct way to do this?
I am now using the native android ThumbnailUtils to create a thumbnail images but if I stream them back into unity as a byte arrays I can’t load them without it being slow again. I haven’t had any luck trying to apply the textures outside of unity. Can someone tell me what’s wrong with this?
Here’s my unity…
AndroidJavaObject ajo = new AndroidJavaObject("com.t2.unityplugin.CreateThumbnail");
ajo.Call("LoadThumbnail", path, (int)newTexture.GetNativeTexturePtr());
And here’s my Java…
public void LoadThumbnail(String path, int pointer){
String newPath = path.replace("file://","");
Bitmap bitmap = BitmapFactory.decodeFile(newPath);
Bitmap thumb = ThumbnailUtils.extractThumbnail(bitmap, 260, 260);
// Bind texture and then copy data
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, pointer);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, thumb, 0);
}
I’ve been stuck on this for days. Any help would be greatly appreciated.