From d9e1f5d6788691620354d30a8189e659d47010a6 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 11 Mar 2025 22:34:29 -0700 Subject: [PATCH] Improve 2D/3D main screen auto-switching logic Co-authored-by: Kit Bishop --- editor/editor_main_screen.cpp | 19 +++++++++++++++++++ editor/editor_main_screen.h | 1 + editor/editor_node.cpp | 22 +++++++++++----------- editor/plugins/script_editor_plugin.cpp | 9 --------- editor/plugins/script_editor_plugin.h | 3 --- editor/plugins/text_editor.h | 1 - 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/editor/editor_main_screen.cpp b/editor/editor_main_screen.cpp index fdd4615c33f6..d6c486c21146 100644 --- a/editor/editor_main_screen.cpp +++ b/editor/editor_main_screen.cpp @@ -233,6 +233,25 @@ EditorPlugin *EditorMainScreen::get_plugin_by_name(const String &p_plugin_name) return main_editor_plugins[p_plugin_name]; } +bool EditorMainScreen::can_auto_switch_screens() const { + if (selected_plugin == nullptr) { + return true; + } + // Only allow auto-switching if the selected button is to the left of the Script button. + for (int i = 0; i < button_hb->get_child_count(); i++) { + Button *button = Object::cast_to