Version: 2022.1
언어: 한국어

OverlayToolbar

class in UnityEditor.Overlays

매뉴얼로 전환

설명

Base class for toolbar elements intended to be drawn in an Overlay.

Use this class with ICreateHorizontalToolbar and ICreateVerticalToolbar to build Overlays that are dockable in toolbars.

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

생성자

OverlayToolbarCreate a new OverlayToolbar.

Public 함수

SetupChildrenAsButtonStripUse this method to apply button strip styling to the contents of this VisualElement.