ソースコード
using UnityEditor;
[InitializeOnLoad]
public static class InspectorHeaderGUI
{
static InspectorHeaderGUI()
{
Editor.finishedDefaultHeaderGUI -= OnGUI;
Editor.finishedDefaultHeaderGUI += OnGUI;
}
private static void OnGUI( Editor editor )
{
if ( !EditorUtility.IsPersistent( editor.target ) )
{
return;
}
var assetPath = AssetDatabase.GetAssetPath( editor.target );
var guid = AssetDatabase.AssetPathToGUID( assetPath );
var totalRect = EditorGUILayout.GetControlRect();
var controlRect = EditorGUI.PrefixLabel( totalRect, EditorGUIUtility.TrTempContent( "GUID" ) );
if ( 1 < editor.targets.Length )
{
var label = EditorGUIUtility.TrTempContent( "[Multiple objects selected]" );
EditorGUI.LabelField( controlRect, label );
}
else
{
EditorGUI.SelectableLabel( controlRect, guid );
}
}
}
使用例
参考サイト様