unity编译器资源帮助类(EditorResHelper)(c#)

FileHelper为博客中另一个文件帮助类

 public class EditorResHelper
{
    /// 获取文件夹内所有的预制跟场景路径
    public static List GetPrefabsAndScenes(string srcPath)
    {
         List paths = new List();
         FileHelper.GetAllFiles(paths, srcPath);
         List files = new List();
         foreach (string str in paths)
        {
            if (str.EndsWith(".prefab") || str.EndsWith(".unity"))
            {
                files.Add(str);
            }
        }
        return files;
    }
    /// 
    /// 获取文件夹内所有资源路径
    /// 
    /// 源文件夹
    /// 是否获取子文件夹
    /// 
    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;
    }
}

你可能感兴趣的:(工作中有用的封装好的代码)