300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片

Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片

时间:2023-03-16 10:53:31

相关推荐

Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片

下边是我自己写的编辑器扩展关于遍历文件夹下边以及子目录下的所有图片,仅提供参考

[MenuItem("编辑器扩展关于图集/C#遍历文件夹以及子目录下的所有图片")]static void RefreshAllPicture(){string[] DebugAllImage = new string[] {};DebugAllImage=KnowAllPicture();}public static string[] KnowAllPicture(){List<string> liststring = new List<string>();string myfolderPath = "PicTureFolder";string path = bine(Application.dataPath, myfolderPath);var images = Directory.GetFiles(path, ".", SearchOption.AllDirectories).Where(s => s.EndsWith(".png") || s.EndsWith(".jpg"));foreach(var i in images){var str = i.Replace(Application.dataPath, "");var strpath = str.Replace("\\", "/");strpath = "Assets" + strpath;liststring.Add(strpath);}foreach(var item in liststring){Debug.Log($"ITem:{item}\n");}return liststring.ToArray();}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。