- Home /
Load image through WWW taking too long
Hi,
I am trying to load an image from a local path (iOS, Android and MAC/PC) and the problem I am having is that it appears to take too long to load image and set the texture.
The way I am downloading image is:
WWW www = new WWW(url);
string filePath = Path.Combine(Application.persistentDataPath, hashedName);
File.WriteAllBytes(filePath, www.bytes);
Then when I know that image is downloaded I load it from local:
if (File.Exists(filePath)) {
www = new WWW("file://" + filePath);
Texture2D tex = www.texture; // This is taking more than half a second!!!
texture.mainTexture = tex;
}
But this last line is taking too long (more than half a second for a high-res picture).
Is there any other way to save the image (instead of getting raw bytes) or anything I could do to improve image loading performance?
Thank you :)
Comment