Unity

GUID Lookup Window for Unity

Have you ever been stuck with a GUID and no convenient way to figure out what asset that it belongs to?

Screenshot of "GUID Lookup" utility window for Unity.

Worry no more!

public class GUIDLookupWindow : EditorWindow
{
	[MenuItem("Bardic/Guid Lookup...")]
	private static void InitWindow()
	{
		var window = GetWindow<GUIDLookupWindow>(true,"Guid Lookup", true);
		window.minSize = new Vector2(350, 50f);
		window.maxSize = new Vector2(700, 75f);
		window.Show();
	}
	private string inputText, pathDisp;

	private void OnGUI()
	{
		GUILayout.BeginVertical();
		GUILayout.Label("Paste GUID, receive asset.");
		GUILayout.BeginHorizontal();
		inputText = EditorGUILayout.TextField("", inputText);
		pathDisp = AssetDatabase.GUIDToAssetPath(inputText);
		GUILayout.EndHorizontal();            
		if(pathDisp != null)
		{
			GUILayout.BeginHorizontal();
			GUILayout.Space(10f);
			GUILayout.Label(pathDisp, EditorStyles.miniLabel);
			GUILayout.EndHorizontal();
			UnityEngine.Object o = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(pathDisp);
			GUILayout.BeginHorizontal();
			GUILayout.FlexibleSpace();
			if (o != null && GUILayout.Button(o.name)) Selection.activeObject = o;
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
		}
		GUILayout.EndVertical();
	}
}