U_AssetDatabase

AssetDatabase
(一个访问资产和对资产执行操作的接口)

https://docs.unity3d.com/ScriptReference/AssetDatabase.html

Path
(对包含文件或目录路径信息的字符串执行操作)

https://docs.unity3d.com/ScriptReference/Path.html

    //获取该路径下的某类型文件 可拓展 "" 内的筛选文本
    private T[] GetAtPath<T>(string path) where T : Object {
        string[] assets = AssetDatabase.FindAssets("", new[] { path});
        T[] ret = new T[assets.Length];
        for (int i = 0; i < assets.Length; i++) {
            T buff = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(assets[i]));
            ret[i] = buff;
        }

        return ret;
    }
posted @ 2022-05-06 10:53  匿鱼  阅读(14)  评论(0编辑  收藏  举报