@@ -17,32 +17,25 @@ public static class FileUtilities
1717 /// Locates the files that match the specified name within the Assets folder structure.
1818 /// </summary>
1919 /// <param name="fileName">The name of the file to locate (ex: "TestFile.asmdef")</param>
20- /// <param name="searchFullFileSystem">If true, searches the full application data path. If false, only searches Unity's known asset database.</param>
2120 /// <returns>Array of FileInfo objects representing the located file(s).</returns>
22- public static FileInfo [ ] FindFilesInAssets ( string fileName , bool searchFullFileSystem = false )
21+ public static FileInfo [ ] FindFilesInAssets ( string fileName )
2322 {
24- if ( searchFullFileSystem )
25- {
26- DirectoryInfo root = new DirectoryInfo ( Application . dataPath ) ;
27- return FindFiles ( fileName , root ) ;
28- }
29- else
23+ // FindAssets doesn't take a file extension
24+ string [ ] assetGuids = AssetDatabase . FindAssets ( Path . GetFileNameWithoutExtension ( fileName ) ) ;
25+
26+ List < FileInfo > fileInfos = new List < FileInfo > ( ) ;
27+ for ( int i = 0 ; i < assetGuids . Length ; i ++ )
3028 {
31- // FindAssets doesn't take a file extension
32- string [ ] assetGuids = AssetDatabase . FindAssets ( Path . GetFileNameWithoutExtension ( fileName ) ) ;
33- List < FileInfo > fileInfos = new List < FileInfo > ( ) ;
34- for ( int i = 0 ; i < assetGuids . Length ; i ++ )
29+ string assetPath = AssetDatabase . GUIDToAssetPath ( assetGuids [ i ] ) ;
30+ // Since this is an asset search without extension, some filenames may contain parts of other filenames.
31+ // Therefore, double check that the path actually contains the filename with extension.
32+ if ( assetPath . Contains ( fileName ) )
3533 {
36- string assetPath = AssetDatabase . GUIDToAssetPath ( assetGuids [ i ] ) ;
37- // Since this is an asset search without extension, some filenames may contain parts of other filenames.
38- // Therefore, double check that the path actually contains the filename with extension.
39- if ( assetPath . Contains ( fileName ) )
40- {
41- fileInfos . Add ( new FileInfo ( assetPath ) ) ;
42- }
34+ fileInfos . Add ( new FileInfo ( assetPath ) ) ;
4335 }
44- return fileInfos . ToArray ( ) ;
4536 }
37+
38+ return fileInfos . ToArray ( ) ;
4639 }
4740
4841 /// <summary>
0 commit comments