Unity 获取指定资源目录下的所有文件

时间:2023-03-08 16:33:59
string path="Assets";//Assets/Scenes
if(Directory.Exists(path)){
DirectoryInfo directoryInfo=new DirectoryInfo(folderPath);
FileInfo[] fileInfos=directoryInfo.GetFiles("*",SearchOption.AllDirectories);
for(int i=0;i<fileInfos.Length;i++){
if(fileInfos[i].Name.EndsWith(".meta"))continue;
if(fileInfos[i].Name.EndsWith(".unity")){
Debug.Log("Name:"+fileInfos[i].Name);
//Debug.Log( "FullName:" + fileInfos[i].FullName );
//Debug.Log( "DirectoryName:" + fileInfos[i].DirectoryName );
}
}
}