获取与 .meta 文本文件关联的资源文件的路径。
using System.IO; using UnityEditor; using UnityEngine;
public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Get All Assets With Meta File")] static void GetAllAssetsWithMetaFiles() { var files = Directory.GetFiles("Assets/", "*.meta", SearchOption.AllDirectories);
foreach (var file in files) { var path = AssetDatabase.GetAssetPathFromTextMetaFilePath(file); Debug.Log(path); } } }