- Home /
load all the textures of a folder into an array through code
I'm making a tiny video - just 3 seconds - to play in my game. The playing part of the code seems alright, but I have to assign 200 textures into an array by hand.
I tried to make something in start() which would access the folder with the textures and create an array that I could use.
This is what I put in start(), but it just says that images is assigned, but never used: Texture2D[] images = Resources.LoadAll("video") as Texture2D[];
Any help would be appreciated. I'd also favor c# as I am quite terrible with js.
You never need to assign items manually by hand one at a time. Just use the lock button: click on the object with the array variable, lock the inspector, select all the textures, drag the lot onto the array variable, then unlock the inspector.
Answer by ForgeStudios · Aug 29, 2013 at 09:29 PM
To your response to what Eric5h5 said, that will put them in order alphabetically, or numerically (hint). But you could also use this possibly:
var arwww : WWW[];
var image : Texture2D[]; //Your array of images, set it to the needed length
var location : String; //The folder of all of your images
function Awake(){
arwww = new WWW[image.Length];
for(i = 0; i < image.length; i++){
arwww[i] = new WWW(location+ "/image"+ i);
arwww[i].LoadImageIntoTexture(image[i]);
}
}
I didn't test that, but I extracted that from a method that i'm using to render texture packs in my game. I hope this helps!
Your answer
![](https://koobas.hobune.stream/wayback/20220613113226im_/https://answers.unity.com/themes/thub/images/avi.jpg)