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
The GUID of the asset, as a string.
Returns
Type | Description |
|---|---|
| string | The 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 . To get the GUID of an asset as a string, use AssetDatabase.AssetPathToGUID.
Assets/MyTextures/hello.pngExamples
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
Returns
Type | Description |
|---|---|
| string | The 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 . To get the GUID of an asset, use AssetDatabase.GUIDFromAssetPath.
Assets/MyTextures/hello.png