Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GUIDToAssetPath

Gets the corresponding asset path for the supplied GUID, or an empty string if the GUID can't be found.
Read time 1 minuteLast updated 8 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor

GUIDToAssetPath(string)

Gets the corresponding asset path for the supplied GUID, or an empty string if the GUID can't be found.
public static string GUIDToAssetPath(string guid)

Parameters

guid

The GUID of an asset.

Returns

Type

Description

stringPath of the asset relative to the project folder.

Remarks

Returned paths are relative to the project folder, for example: "Assets/MyTextures/hello.png".
using UnityEditor;using UnityEngine;public class GUIDToAssetPathExample : MonoBehaviour{ [MenuItem("APIExamples/GUIDToAssetPath")] static void MaterialPathsInProject() { var allMaterials = AssetDatabase.FindAssets("t: Material"); foreach (var guid in allMaterials) { var path = AssetDatabase.GUIDToAssetPath(guid); Debug.Log(path); } }}
See AssetDatabase.AssetPathToGUID for a version that returns a string instead of a GUID.

GUIDToAssetPath(GUID)

Gets the corresponding asset path for the supplied GUID, or an empty string if the GUID can't be found.
public static string GUIDToAssetPath(GUID guid)

Parameters

guid

GUID
The GUID of an asset.

Returns

Type

Description

stringPath of the asset relative to the project folder.

Remarks

Returned paths are relative to the project folder, for example: "Assets/MyTextures/hello.png".
using UnityEditor;using UnityEngine;public class GUIDToAssetPathExample : MonoBehaviour{ [MenuItem("APIExamples/GUIDToAssetPath")] static void MaterialPathsInProject() { var allMaterials = AssetDatabase.FindAssets("t: Material"); foreach (var guid in allMaterials) { var path = AssetDatabase.GUIDToAssetPath(guid); Debug.Log(path); } }}
See AssetDatabase.AssetPathToGUID for a version that returns a string instead of a GUID.