获取 所有资源
[@MenuItem("Navy/Assets/Test")]
static void Test_Compoent(){
//OK
//这个不好用~
//Debug.Log(AssetDatabase.LoadAllAssetsAtPath("Assets/Models/21/21000001/21000001.prefab").Length);
//设置进度条
EditorUtility.DisplayProgressBar("设置AssetName名称", "正在设置AssetName名称中...", 0.50f);
EditorUtility.ClearProgressBar();
//路径
string fullPath = "Assets/Models/21/21000001" + "/";
//获取指定路径下面的所有资源文件
if (Directory.Exists(fullPath)){
DirectoryInfo direction = new DirectoryInfo(fullPath);
FileInfo[] files = direction.GetFiles("*",SearchOption.AllDirectories);
Debug.Log(files.Length);
for(int i=0;i<files.Length;i++){
if (files[i].Name.EndsWith(".meta")){
continue;
}
Debug.Log( "Name:" + files[i].Name );
//Debug.Log( "FullName:" + files[i].FullName );
//Debug.Log( "DirectoryName:" + files[i].DirectoryName );
}
}
}
本文介绍了一种在Unity编辑器中使用C#脚本批量获取并显示指定目录下所有资源文件名称的方法,并通过简单的菜单项调用实现,有助于提高资源管理效率。
6765

被折叠的 条评论
为什么被折叠?



