Add guit to asset path

This commit is contained in:
Hubert Mattusch 2022-11-30 04:22:46 +01:00
parent 1e3aa619eb
commit 00057a04b8
2 changed files with 44 additions and 0 deletions

41
Editor/GUIDToAssetPath.cs Normal file
View File

@ -0,0 +1,41 @@
using UnityEditor;
using UnityEngine;
public class GUIDToAssetPath : EditorWindow
{
string guid = "";
string path = "";
[MenuItem("Tools/GUIDToAssetPath")]
static void CreateWindow()
{
GUIDToAssetPath window = (GUIDToAssetPath)EditorWindow.GetWindowWithRect(typeof(GUIDToAssetPath), new Rect(0, 0, 400, 120));
}
void OnGUI()
{
GUILayout.Label("Enter guid");
guid = GUILayout.TextField(guid);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Get Asset Path",GUILayout.Width(120)))
path = GetAssetPath(guid);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Abort", GUILayout.Width(120)))
Close();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Label(path);
}
static string GetAssetPath(string guid)
{
guid = guid.Replace("-", "");
string p = AssetDatabase.GUIDToAssetPath(guid);
Debug.Log(p);
if (p.Length == 0) p = "not found";
return p;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ee5c0a00075140f28ac5e6ff46e9a6b3
timeCreated: 1669777021