Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

AssetDatabase.GUIDToAssetPath

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static string GUIDToAssetPath(string guid);

Parameters

Parameter Description
guid The GUID of the asset, as a string.

Returns

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

Description

Gets the path of the asset with a GUID in string form, relative to the project folder.

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.

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

Declaration

public static string GUIDToAssetPath(GUID guid);

Parameters

Parameter Description
guid The GUID of the asset.

Returns

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

Description

Gets the path of the asset with the specified GUID, relative to the project folder.

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.