Version: 2022.1
言語: 日本語
public IEnumerable<string> toolbarElements ;

説明

Use toolbarElements to specify the contents of this Overlay.

using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Overlays;
using UnityEditor.Toolbars;
using UnityEngine;
using UnityEngine.UIElements;

[Overlay(typeof(SceneView), "My Toolbar Overlay")]
class MyOverlay : Overlay, ICreateToolbar
{
    static readonly string[] k_ToolbarItems = new[]
    {
        "MyToolbarItem",
        "SomeOtherToolbarItem"
    };

    public override VisualElement CreatePanelContent()
    {
        return new Label("I'm the content shown in panel mode!");
    }

    public IEnumerable<string> toolbarElements => k_ToolbarItems;
}

[EditorToolbarElement("SomeOtherToolbarItem", typeof(SceneView))]
class SomeOtherToolbarItem : EditorToolbarToggle
{
    public SomeOtherToolbarItem()
    {
        icon = EditorGUIUtility.FindTexture("CustomTool");
    }
}

// Example toolbar element with multiple controls
[EditorToolbarElement("MyToolbarItem", typeof(SceneView))]
class MyToolbarItem : OverlayToolbar
{
    public MyToolbarItem()
    {
        var icon = AssetDatabase.LoadAssetAtPath<Texture2D>("MyIcon");
        Add(new EditorToolbarButton(icon, () => { Debug.Log("Hello!"); }));
        Add(new EditorToolbarButton(icon, () => { Debug.Log("Hello again!"); }));
        SetupChildrenAsButtonStrip();
    }
}
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961