Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

MainToolbarElementAttribute

class in UnityEditor.Toolbars

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Registers a static method you can use to extend the main toolbar with custom UI elements.

Methods tagged with this attribute return a MainToolbarElement or one of its child types. Each MainToolbarElement describes the content and behaviour of a toolbar element and the main toolbar queries these methods when it needs to create or update its toolbar elements.

using UnityEditor;
using UnityEditor.Toolbars;
using UnityEngine;

public class MainToolbarButtonExample
{
    [MainToolbarElement("Examples/Open Project Settings", defaultDockPosition = MainToolbarDockPosition.Middle)]
    public static MainToolbarElement ProjectSettingsButton()
    {
        var icon = EditorGUIUtility.IconContent("SettingsIcon").image as Texture2D;
        var content = new MainToolbarContent(icon);
        return new MainToolbarButton(content, () => { SettingsService.OpenProjectSettings(); });
    }
}

Static Properties

Property Description
defaultMenuPriorityThe default value for MainToolbarElement.menuPriority. Specify a priority lower than this value to display a main toolbar element's menu item before the default entries, or specify a higher value to display it after the default entries.

Properties

Property Description
defaultDockIndexSpecify the order in which custom elements are docked in the main toolbar.
defaultDockPositionUse this property to specify the default dock position of the element: the left, the middle, or the right.
menuPriorityMenu priority defines the order that main toolbar elements are displayed in within the toolbar's menu.
pathThe unique identifier of this toolbar element.