@@ -2719,7 +2719,11 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
27192719 SceneTreeDock::get_singleton ()->set_selection ({ current_node });
27202720 InspectorDock::get_singleton ()->update (current_node);
27212721 if (!inspector_only && !skip_main_plugin) {
2722- skip_main_plugin = stay_in_script_editor_on_node_selected && !ScriptEditor::get_singleton ()->is_editor_floating () && ScriptEditor::get_singleton ()->is_visible_in_tree ();
2722+ if (!ScriptEditor::get_singleton ()->is_editor_floating () && ScriptEditor::get_singleton ()->is_visible_in_tree ()) {
2723+ skip_main_plugin = stay_in_script_editor_on_node_selected;
2724+ } else {
2725+ skip_main_plugin = !editor_main_screen->can_auto_switch_screens ();
2726+ }
27232727 }
27242728 } else {
27252729 NodeDock::get_singleton ()->set_node (nullptr );
@@ -2798,9 +2802,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
27982802 if (!changing_scene) {
27992803 main_plugin->edit (current_obj);
28002804 }
2801- }
2802-
2803- else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton () || !ScriptEditor::get_singleton ()->is_visible_in_tree () || ScriptEditor::get_singleton ()->can_take_away_focus ())) {
2805+ } else if (main_plugin != editor_plugin_screen) {
28042806 // Unedit previous plugin.
28052807 editor_plugin_screen->edit (nullptr );
28062808 active_plugins[editor_owner_id].erase (editor_plugin_screen);
@@ -3998,18 +4000,15 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
39984000 changing_scene = false ;
39994001
40004002 if (get_edited_scene ()) {
4001- int current_tab = editor_main_screen->get_selected_index ();
4002- if (current_tab < 2 ) {
4003+ if (editor_main_screen->can_auto_switch_screens ()) {
40034004 // Switch between 2D and 3D if currently in 2D or 3D.
40044005 Node *selected_node = SceneTreeDock::get_singleton ()->get_tree_editor ()->get_selected ();
40054006 if (!selected_node) {
40064007 selected_node = get_edited_scene ();
40074008 }
4008-
4009- if (Object::cast_to<CanvasItem>(selected_node)) {
4010- editor_main_screen->select (EditorMainScreen::EDITOR_2D);
4011- } else if (Object::cast_to<Node3D>(selected_node)) {
4012- editor_main_screen->select (EditorMainScreen::EDITOR_3D);
4009+ const int plugin_index = editor_main_screen->get_plugin_index (editor_data.get_handling_main_editor (selected_node));
4010+ if (plugin_index >= 0 ) {
4011+ editor_main_screen->select (plugin_index);
40134012 }
40144013 }
40154014 }
@@ -7710,6 +7709,7 @@ EditorNode::EditorNode() {
77107709
77117710 HBoxContainer *main_editor_button_hb = memnew (HBoxContainer);
77127711 main_editor_button_hb->set_mouse_filter (Control::MOUSE_FILTER_STOP);
7712+ main_editor_button_hb->set_name (" EditorMainScreenButtons" );
77137713 editor_main_screen->set_button_container (main_editor_button_hb);
77147714 title_bar->add_child (main_editor_button_hb);
77157715 title_bar->set_center_control (main_editor_button_hb);
0 commit comments