ok I’ve managed to do a loop of 5 Subfolders and all files in them
but I wander how do I create a loop that loops it self and knows he’s own loop changes a bit each time it loops it self of it has finished it’s loop
I know it’s a bit complicated - how do I make this code going infinitive (or untill last subfolder found)
public List`<`TextureC> texturec ;
public string[] dirPaths;
public string[] dirPaths1;
public string[] dirPaths2;
public string[] dirPaths3;
public string[] dirPaths4;
public string[] dirPaths5;
public string[] filePaths;
public string[] filePaths1;
public string[] filePaths2;
public string[] filePaths3;
public string[] filePaths4;
public string[] filePaths5;
void ResizeTextures(){
dirPaths = Directory.GetDirectories(Application.dataPath + "/Resources/Textures/");
for (int di = 0; di < dirPaths.Length ; di++){
filePaths = Directory.GetFiles(dirPaths[di]);
for (int fi = 0; fi < filePaths.Length; fi++){
texturec.Add (new TextureC (filePaths[fi]));
}
dirPaths1 = Directory.GetDirectories(dirPaths[di]);
for (int dii = 0; dii < dirPaths1.Length; dii++){
filePaths1 = Directory.GetFiles(dirPaths1[dii]);
for (int fii = 0; fii < filePaths1.Length; fii++) {
texturec.Add (new TextureC (filePaths1[fii]));
}
dirPaths2 = Directory.GetDirectories(dirPaths1[dii]);
for (int diii = 0; diii < dirPaths2.Length; diii++){
filePaths2 = Directory.GetFiles(dirPaths2[diii]);
for (int fiii = 0; fiii < filePaths2.Length; fiii++) {
texturec.Add (new TextureC (filePaths2[fiii]));
}
dirPaths3 = Directory.GetDirectories(dirPaths2[diii]);
for (int diiii = 0; diiii < dirPaths3.Length; diiii++){
filePaths3 = Directory.GetFiles(dirPaths3[diiii]);
for (int fiiii = 0; fiiii < filePaths3.Length; fiiii++) {
texturec.Add (new TextureC (filePaths3[fiiii]));
}
dirPaths4 = Directory.GetDirectories(dirPaths3[diiii]);
for (int diiiii = 0; diiiii < dirPaths4.Length; diiiii++){
filePaths4 = Directory.GetFiles(dirPaths4[diiiii]);
for (int fiiiii = 0; fiiiii < filePaths4.Length; fiiiii++) {
texturec.Add (new TextureC (filePaths4[fiiiii]));
}
dirPaths5 = Directory.GetDirectories(dirPaths4[diiiii]);
for (int diiiiii = 0; diiiiii < dirPaths5.Length; diiiiii++){
filePaths5 = Directory.GetFiles(dirPaths5[diiiiii]);
for (int fiiiiii = 0; fiiiiii < filePaths5.Length; fiiiiii++) {
texturec.Add (new TextureC (filePaths5[fiiiiii]));
}
}
}
}
}
}
}
}
and if you wander about class (nothing special yet)
my Class
using UnityEngine;
using System.Collections;
[System.Serializable]
public class TextureC {
public string names ;
public string paths ;
public string filenames ;
public Texture2D texture ;
// Constructors
public TextureC (){}
public TextureC (string path){
paths = path ;
}
public TextureC (Texture2D tex){
texture = tex ;
}
}
sorry about generic list forgot how to make >< visible around TextureC (public list TextureC texturec)