- Home /
What is the correct way to store 1000's of images in a Unity project?
I have a project that is basically a kind of gallery. I have 1000s of images (probably 10k+).
The user can filter these images by picking keywords, and then when they submit, it loads a couple hundred game objects into the scene and applies each image as a texture.
My question is what is the correct way to go about this? Right now, I am putting the images in the resources folder but that seems wrong.
Storing the images online and grabbing them with the WWW object isn't really an option as the yield is too slow.
Is there a correct way to go about this?
i would use tinglers approach with texture2d.loadimage.
unfortunatly you simply cant load that much data into the users ram without crashing your user's as there PC runs out of memory.
If you put all the images locally on a hard drive folder you could get the directory lising of all of them for sorting. Then come up with a creative way to use texture2d.loadimage to load/unload only the images that need to be currently displayed displayed at the time.
if you are writing for PC reading and writing to the hard drive is easy enough.
your images could also be downloaded from a server too. as a side note ... if you don't have a server, unity can take any files directly from dropbox as well !!!
I do have a server but downloading 1000 images is just too slow to download for when I'm loading them for the user. I think I'll have to find a local disk solution like you said. It is exclusively for PC so at least I have that.
Answer by tinglers · Mar 10, 2017 at 03:53 PM
You could use the texture2d.loadimage to load it directly from disk and store it there. You can also try asset bundles but you got to remember that loading hundreds of images just takes time.
I'm having trouble understanding what texture2d.loadimage does exactly and why it would be beneficial for me?
I didn't think of asset bundles. I could definitely separate the images into bundles 1000 or less. Would I then store the bundle inside the Assets folder or do I store it somewhere on my HDD and the build only works on my HDD?
Loadimage would be only a temp solution, Asset bundles are folders that can exist outside of a project and still be accessed real-time, so check the documentation on it