获取与文本 .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); } } }