ソースコード
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
[InitializeOnLoad]
public static class Example
{
static Example()
{
EditorApplication.delayCall += () =>
{
var assembly = typeof( EditorWindow ).Assembly;
var type = assembly.GetType( "UnityEditor.GameView" );
var gameview = EditorWindow.GetWindow( type );
var toolbar = new VisualElement();
var style = toolbar.style;
var rootVisualElement = gameview.rootVisualElement;
style.flexDirection = FlexDirection.Row;
style.top = 20;
style.height = 20;
toolbar.Add( new Label { text = "ピカチュウ" } );
toolbar.Add( new Button( () => Debug.Log( "ピカチュウ" ) ) { text = "ピカチュウ" } );
toolbar.BringToFront();
rootVisualElement.Clear();
rootVisualElement.Add( toolbar );
};
}
}
関連記事