语言English
  • C#

Provider.GetAssetByGUID

声明

public static VersionControl.Asset GetAssetByGUID(string guid);

参数

guid 资源的 GUID。

描述

根据给定的 GUID 返回资源的版本控制信息。

如果 Unity 编辑器中不识别该 GUID,则返回 null。

using System.Collections.Generic;
using UnityEditor;
using UnityEditor.VersionControl;
using UnityEngine;

public class EditorScript : MonoBehaviour { [MenuItem("Version Control/GetAssetByGUID")] static void ExampleGetAssetByGUID() { string guid = AssetDatabase.AssetPathToGUID("Assets/ExampleAsset.mat"); AssetList assets = new AssetList(); assets.Add(Provider.GetAssetByGUID(guid)); Debug.Log("Found an asset: " + assets[0].name.ToString()); } }

Did you find this page useful? Please give it a rating: