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

来源:互联网 发布:约瑟夫环c语言循环链式 编辑:程序博客网 时间:2024/05/29 18:35
  1.  //路径  
  2.         string fullPath = "Assets/Models/21/21000001" + "/";  
  3.   
  4.         //获取指定路径下面的所有资源文件  
  5.         if (Directory.Exists(fullPath)){  
  6.             DirectoryInfo direction = new DirectoryInfo(fullPath);  
  7.             FileInfo[] files = direction.GetFiles("*",SearchOption.AllDirectories);  
  8.   
  9.             Debug.Log(files.Length);  
  10.   
  11.             for(int i=0;i<files.Length;i++){  
  12.                 if (files[i].Name.EndsWith(".meta")){  
  13.                     continue;  
  14.                 }  
  15.                 Debug.Log( "Name:" + files[i].Name );  
  16.                 //Debug.Log( "FullName:" + files[i].FullName );  
  17.                 //Debug.Log( "DirectoryName:" + files[i].DirectoryName );  
  18.             }  
  19.         }  
0 1
原创粉丝点击