以下の内容はhttps://baba-s.hatenablog.com/entry/2019/11/26/170000より取得しました。


【Unity】UIElements で Game ビューにテキストやボタンを追加するエディタ拡張のサンプル

ソースコード

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 );
        };
    }
}

f:id:baba_s:20191125134903p:plain

関連記事




以上の内容はhttps://baba-s.hatenablog.com/entry/2019/11/26/170000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14