-
Notifications
You must be signed in to change notification settings - Fork 6
Close tabs
Unreal Engine and web browsers provide tab management options like "Close other tabs" and "Close tabs to the right". Unity provides single option "Close Tab". So the idea of close tabs is to implement logic similar to Unreal Engine and web browsers.
It turns out there is no simple way to support that for built-in Unity editor windows like "Scene", "Game", "Inspector" etc. However it is possible to implement that for custom editor windows via UnityEditor.IHasCustomMenu interface. Thus close tabs provides both base class PumpEditor.EditorWindowWithCloseTabs to inherit from and PumpEditor.CloseTabsHelper helper class to populate custom menu if inheritance is not an option.
Inherit this class to get close tab menu options for your editor window. Note that you can override PumpEditor.EditorWindowWithCloseTabs.AddItemsToMenu virtual method to add your own menu items if needed.
If inheritance is not an option, implement UnityEditor.IHasCustomMenu by your editor window. The in the AddItemsToMenu method implemenetation call PumpEditor.CloseTabsHelper methods to add close tabs menu items:
// ...
public class MyEditorWindow : EditorWindow, IHasCustomMenu
{
// ...
public void AddItemsToMenu(GenericMenu menu)
{
CloseTabsHelper.AddCloseOtherTabsItem(this, menu);
CloseTabsHelper.AddCloseTabsToTheRightItem(this, menu);
}
}Either implementation option results in new menu items added to the tab right click menu. Note that "Close Tabs to the Right" is disabled as there are no tabs to the right from the selected tab.
For maximized window both close tabs options are disabled.
