using System.Collections.Generic; using System.IO; namespace Model { public class EditorResHelper { /// /// 获取文件夹内所有的预制路径 /// /// 源文件夹 /// 是否获取子文件夹 /// public static List GetAllPath(string srcPath, bool subDire) { List paths = new List(); string[] files = Directory.GetFiles(srcPath); foreach (string str in files) { if (str.EndsWith(".prefab")) { paths.Add(str); } } if (subDire) { foreach (string subPath in Directory.GetDirectories(srcPath)) { List subFiles = GetAllPath(subPath, true); paths.AddRange(subFiles); } } return paths; } /// /// 获取文件夹内所有资源路径 /// /// 源文件夹 /// 是否获取子文件夹 /// public static List GetAllResourcePath(string srcPath, bool subDire) { List paths = new List(); string[] files = Directory.GetFiles(srcPath); foreach (string str in files) { if (str.EndsWith(".meta")) { continue; } paths.Add(str); } if (subDire) { foreach (string subPath in Directory.GetDirectories(srcPath)) { List subFiles = GetAllResourcePath(subPath, true); paths.AddRange(subFiles); } } return paths; } } }