博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Unity获取指定资源目录下的所有文件
阅读量:6947 次
发布时间:2019-06-27

本文共 866 字,大约阅读时间需要 2 分钟。

使用前需要引入System.IO;这个命名空间

1 public void GetFiles() 2 { 3     //路径  4     //string path = string.Format("{0}", Application.streamingAssetsPath); 5     string path = string.Format("{0}", @"D:\SHU170221U3D-09\Lesson14\Assets\StreamingAssets"); 6  7     //获取指定路径下面的所有资源文件   8     if (Directory.Exists(path)) 9     {10         DirectoryInfo direction = new DirectoryInfo(path);11         FileInfo[] files = direction.GetFiles("*", SearchOption.AllDirectories);12 13         Debug.Log(files.Length);14 15         for (int i = 0; i < files.Length; i++)16         {17             if (files[i].Name.EndsWith(".meta"))18             {19                 continue;20             }21             Debug.Log("Name:" + files[i].Name);22             Debug.Log("FullName:" + files[i].FullName);23             Debug.Log("DirectoryName:" + files[i].DirectoryName);24         }25     }26 }

 

转载地址:http://sbenl.baihongyu.com/

你可能感兴趣的文章