2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Unity】たまに使うアセットのGUIDを確認するWindow

Posted at

image.png

なんだかんだ.metaファイルやアセットバンドルやシーンのトラブルシューティングで使うやつ

using UnityEngine;
using UnityEditor;

namespace AssetTool {
	public static class FindGUID  {

		[MenuItem("Tools/Find by GUID")]
		static void Start() {
			FindGUIDWindow.Open();
		}
				
	}
	
	public class FindGUIDWindow : EditorWindow {

		private Object asset;
		private string guid;

		public static void Open() {
			var window = (FindGUIDWindow) GetWindow(typeof(FindGUIDWindow));
			window.titleContent = new GUIContent("Find GUID");
			window.Show();                
		}

		private void OnGUI() {
			GUILayout.Label("GUIDを入力するとアセットを検索します。\nまたはアセットをドラッグ&ドロップするとGUIDを表示します。");
			
			var oldGUID = guid;
			guid = EditorGUILayout.TextField("GUID", guid);
			if (oldGUID != guid) {
				asset = AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(guid));
			}

			var oldAsset = asset;
			asset = EditorGUILayout.ObjectField(asset,typeof(Object),false);
			if (asset != oldAsset) {
				guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset));
			}
		}
	}	
}

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?