使用AssetDatabase.FindAssets获取指定路径下资源。
如下,获取指定路径下所有资源名:
1 string[] pathArr = { ConstUtils.cfgPrefix_ActionTimeline }; 2 private Dictionary<string, string> names = new(); 3 4 public Dictionary<string, string> GetTimelineNames() 5 { 6 names.Clear(); 7 #if UNITY_EDITOR 8 var assetsGuid = AssetDatabase.FindAssets("t:ActionTimelineProfile", pathArr); 9 for (var i = 0; i < assetsGuid.Length; i++) 10 { 11 var guid = assetsGuid[i]; 12 var path = AssetDatabase.GUIDToAssetPath(guid); 13 var lastIndex = path.LastIndexOf('/'); 14 if (lastIndex >= 0) 15 { 16 var name = (path.Substring(lastIndex + 1)).Replace(".asset", ""); 17 names.Add(name, name); 18 } 19 } 20 #endif 21 return names; 22 }
标签:name,assetsGuid,指定,lastIndex,unity,names,var,editor From: https://www.cnblogs.com/sun-shadow/p/16772880.html