Version: 2021.2
言語: 日本語
public static GUID GUIDFromAssetPath (string path);

パラメーター

path Filesystem path for the asset. All paths are relative to the project folder.

戻り値

GUID The GUID of the asset. An all-zero GUID denotes an invalid asset path.

説明

アセットのパスから GUID を取得します

すべてのパスは、例えば "Assets/MyTextures/hello.png" のような Project フォルダーに対する相対パスです。

using UnityEngine;
using UnityEditor;

public static class Example { [MenuItem("AssetDatabase/GUIDFromAssetPath")] static void Doit() { GUID t = AssetDatabase.GUIDFromAssetPath("Assets/texture.jpg"); Debug.Log(t.ToString()); } }