43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
public class GUIDToAssetPath : EditorWindow
|
|
{
|
|
private string guid = "";
|
|
private string path = "";
|
|
|
|
private 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);
|
|
}
|
|
|
|
[MenuItem("Tools/GUIDToAssetPath")]
|
|
private static void CreateWindow()
|
|
{
|
|
var window = (GUIDToAssetPath)GetWindowWithRect(typeof(GUIDToAssetPath), new Rect(0, 0, 400, 120));
|
|
}
|
|
|
|
private 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;
|
|
}
|
|
} |