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

@ -1,7 +1,13 @@
using UnityEngine;
#if UNITY_6000_3_OR_NEWER
using System;
#endif
namespace Module.NavigationTool.Editor.Toolbar
{
#if UNITY_6000_3_OR_NEWER
[Obsolete("Unity has added a new API for adding elements to the main toolbar. Check: <url=https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Toolbars.MainToolbarElement.html>MainToolbarElement</url>.")]
#endif
public abstract class AbstractToolbarDrawer
{
public abstract bool Visible { get; }
@ -9,18 +15,22 @@ namespace Module.NavigationTool.Editor.Toolbar
public abstract EToolbarPlacement Placement { get; }
public abstract int Priority { get; }
private Rect rect;
protected Styles styles;
#if !UNITY_6000_3_OR_NEWER
private Rect rect;
public void Setup(Rect rect)
{
this.rect = rect;
}
#endif
public virtual void Update()
{
}
#if !UNITY_6000_3_OR_NEWER
public void OnGUI()
{
if (styles == null)
@ -32,6 +42,7 @@ namespace Module.NavigationTool.Editor.Toolbar
Draw(rect);
GUI.enabled = true;
}
#endif
protected abstract void Draw(Rect rect);
public abstract float CalculateWidth();