In my program, i want the user to have access to thousands of different photos that he/she can view. The photos are loaded from a server and stored on the users hard drive. If the photo is already stored on the HD, the program uses the photo rather then downloading it again.
As it takes waaay to long to setup and texture 5000 objects at once, i load them in pairs of 20. The user can then scroll (using a regular scrollbar) to move the line of photos.
Once the image is downloaded i do the following:
Texture2D asd = new Texture2D(200, 200, TextureFormat.ARGB32, false);
asd.LoadImage(System.IO.File.ReadAllBytes(RESOURCE_DIRECTORY + imageName));
renderer.material.mainTexture = asd;
It all seems to be working fine. The only problem is that i takes along time to apply the texture. It averages about 0.013 seconds on my computer (which is a very new one). That may not seem like much, but as i use a scrollbar, i have to wait 0.3 every time the OnGUI updates and receivs a new value from the scrollbar.
So my question: Is there a faster way of doing this?
My testing indicates that it is the LoadImage() that is the time consumer. WOuld using getPixels/setPixels enhance my performance?
The way i understand it, having the image in the assets/resource-folder will speed things up greately, but thats only if the image is there when i compile, right?
I appriciate all help and feed back.