Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GUIDToAssetPath

Gets the path of the asset with a GUID in string form, relative to the project folder.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

GUIDToAssetPath(string)

Gets the path of the asset with a GUID in string form, relative to the project folder.
public static string GUIDToAssetPath(string guid)

Parameters

guid

The GUID of the asset, as a string.

Returns

Type

Description

stringThe project-relative path of the asset, or an empty string if no asset has the GUID.

Remarks

Use this method to find where an asset is stored when you have its GUID. Paths are relative to the project folder, for example
Assets/MyTextures/hello.png
. To get the GUID of an asset as a string, use AssetDatabase.AssetPathToGUID.

Examples

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); } }}

GUIDToAssetPath(GUID)

Gets the path of the asset with the specified GUID, relative to the project folder.
public static string GUIDToAssetPath(GUID guid)

Parameters

guid

GUID
The GUID of the asset.

Returns

Type

Description

stringThe project-relative path of the asset, or an empty string if no asset has the GUID.

Remarks

Use this method to find where an asset is stored when you have its GUID. Paths are relative to the project folder, for example
Assets/MyTextures/hello.png
. To get the GUID of an asset, use AssetDatabase.GUIDFromAssetPath.