Automatic Array Importing

Lets say I have 272 bitmaps in a folder in the project library and I want them all imported into one array by script. How would I go about doing that?

Is it even possible?

Create a Resources folder if you haven’t already done so, and put all your images in it. Then make a delimited text file (also in Resources folder) with the array info, i.e. image1, image2, etc… Then make a script that loads the text file and parses it into the array. Use Resources.Load to get the pictures. Now all you have to do make changes is edit the text file. To create the text file initially, you can use whatever external script or language you’re comfortable with that can point at a folder, read the filenames and write out a textfile. Or you can create the textfile by hand; it will still save you some time and effort and make tweaking easier. Also, since the array is just strings of the paths to the pics, rather than actual textures, the memory footprint is way better, I think.

HTH, I feel/have felt your (wrist) pain dragging hundreds of pics in the editor. :slight_smile:

Or use a simple editor script and get rid of all the hassle with loading resources at runtime and file i/o. It should be fairly easy to adapt the Texture Import Settings script i linked to in your other thread.

I agree this would be extremely useful (an editor script you could just point at a folder and automagically build arrays), but simple and easy are not the words I would use to describe it - for me, the word “possible” is a stretch…

Perhaps Martin will come to the rescue! Those import scripts have certainly saved me lots of RSI, bless his heart.

Are this editor script functions documented somewhere? I’m having a hard time figuring this out.

search for “Editor” in the script reference, and read “Extending the Editor” in the manual.

Hrm, this would be a nice little project to learn editor scripting…

Solved it now with the very simple function: Resources.LoadAll

:smile: