【unity】在EditorWindow添加自定义的Toolbar按钮

好久没写了,最近做工具,写了个EditorWindow,为了让使用者方便查看这个工具的文档,想着在导航栏加个问号按钮,点一下打开说明文档就完事~

查了下unity手册,发现Unity提供了一个 ShowButton 方法,用于在自定义Editor窗口的工具栏中添加自定义内容,下面是实现的例子:

复制代码
   private GUIStyle helpBtn;

    private void ShowButton(Rect position)
    {
        if (helpBtn == null)
        {
            helpBtn = new GUIStyle(GUI.skin.button)
            {
                padding = new RectOffset()
            };
        }

        if (GUI.Button(position, UnityEditor.EditorGUIUtility.IconContent("_Help"), helpBtn))
        {
            Application.OpenURL("百度一下,你就知道 (baidu.com)");//随便搞的网址
        }
    }
复制代码

需要直接cv吧~

 

posted @   邪心鳞宝  阅读(205)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示