Navigation tools upgraded to use the new MainToolbarElement API

This commit is contained in:
Anders Ejlersen 2025-12-06 15:17:30 +01:00
parent 708b99f763
commit 3e1602162c
52 changed files with 837 additions and 66 deletions

View file

@ -0,0 +1,29 @@
#if UNITY_6000_3_OR_NEWER
using UnityEditor;
using UnityEditor.Toolbars;
using UnityEngine;
using UnityEngine.Scripting;
namespace Module.NavigationTool.Editor.Toolbar
{
internal static class MainToolbarProjectSettingsElement
{
[Preserve]
[MainToolbarElement("Toolbar/Project/Open Settings", ussName = "", defaultDockIndex = 100, defaultDockPosition = MainToolbarDockPosition.Middle, menuPriority = 1500)]
public static MainToolbarElement Draw()
{
var icon = EditorGUIUtility.IconContent("Settings").image as Texture2D;
var content = new MainToolbarContent(icon, "Opens Preferences/Project Settings");
return new MainToolbarDropdown(content, OnDropdownOpen);
}
private static void OnDropdownOpen(Rect rect)
{
var menu = new GenericMenu();
menu.AddItem(new GUIContent("Preferences"), false, () => SettingsService.OpenUserPreferences("Module/Toolbar"));
menu.AddItem(new GUIContent("Project Settings"), false, () => SettingsService.OpenProjectSettings("Module/Toolbar"));
menu.DropDown(rect);
}
}
}
#endif