Version: 2021.1

AssetDatabase.GetAssetPathFromTextMetaFilePath

切换到手册
public static string GetAssetPathFromTextMetaFilePath (string path);

描述

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