Works up to Unity 6.2!. From Unity 6.3 and onwards there is the Toolbar API with static methods and attributes.
A Unity package that allows you to extend the Unity Editor toolbar with custom buttons and controls using Visual Elements.

"com.alexandros.unity-toolbar-extender": "https://github.com/alexisstrat/unity-toolbar-extender.git?path=/Packages/com.alexandros.unity-toolbar-extender"- Create a new Configuration via create -> Toolbar Extender/Configuration.
- Create a scriptable object that inherits from
ToolbarElement.csand implement theCreateElementmethod. - Add the scriptable object to the
ToolbarElementfield in the configuration.
Inherit from ToolbarButton and implement the OnClick method.
[CreateAssetMenu(menuName = "Toolbar Extender/Example Button")]
public class ExampleToolbarButton : ToolbarButton
{
protected override void OnClick()
{
Debug.Log("Example Toolbar Button Clicked!");
}
}Inherit from ToolbarSlider and implement the OnValueChanged method.
[CreateAssetMenu (menuName = "Toolbar Extender/Example Slider")]
public class ExampleSlider : ToolbarSlider
{
protected override void OnValueChanged(float newValue)
{
Debug.Log($"Slider value changed: {newValue}");
}
}When moving UnityEditor to a different resolution monitor, the toolbar may disappear. Find your configuration scriptable and click "Manual Refresh" or recompile.
