diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index bdf99c849ce..a8a0f6e5e45 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1078,6 +1078,9 @@ If [code]true[/code], the floating panel position, size, and screen will be saved on editor exit. On next launch the panels that were floating will be made floating in the saved positions, sizes and screens, if possible. + + If [code]true[/code], the FileSystem dock will automatically navigate to the currently selected scene tab. + Controls when the Close (X) button is displayed on scene tabs at the top of the editor. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3cb921391d6..ce1c82faf70 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4513,10 +4513,23 @@ void EditorNode::_set_current_scene_nocheck(int p_idx) { callable_mp(this, &EditorNode::_set_main_scene_state).call_deferred(state, get_edited_scene()); // Do after everything else is done setting up. } + if (!select_current_scene_file_requested && EDITOR_GET("interface/scene_tabs/auto_select_current_scene_file")) { + select_current_scene_file_requested = true; + callable_mp(this, &EditorNode::_nav_to_selected_scene).call_deferred(); + } + _update_undo_redo_allowed(); _update_unsaved_cache(); } +void EditorNode::_nav_to_selected_scene() { + select_current_scene_file_requested = false; + const String scene_path = editor_data.get_scene_path(scene_tabs->get_current_tab()); + if (!scene_path.is_empty()) { + FileSystemDock::get_singleton()->navigate_to_path(scene_path); + } +} + void EditorNode::setup_color_picker(ColorPicker *p_picker) { p_picker->set_editor_settings(EditorSettings::get_singleton()); int default_color_mode = EditorSettings::get_singleton()->get_project_metadata("color_picker", "color_mode", EDITOR_GET("interface/inspector/default_color_picker_mode")); diff --git a/editor/editor_node.h b/editor/editor_node.h index c28b3e4fb68..35b0a18c672 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -454,6 +454,8 @@ private: bool waiting_for_first_scan = true; bool load_editor_layout_done = false; + bool select_current_scene_file_requested = false; + HashSet> tracked_translations; bool pending_translation_notification = false; @@ -592,6 +594,7 @@ private: void _set_current_scene(int p_idx); void _set_current_scene_nocheck(int p_idx); + void _nav_to_selected_scene(); bool _validate_scene_recursive(const String &p_filename, Node *p_node); void _save_scene(String p_file, int idx = -1); void _save_all_scenes(); diff --git a/editor/settings/editor_settings.cpp b/editor/settings/editor_settings.cpp index f692aa4aec1..0c50bb64465 100644 --- a/editor/settings/editor_settings.cpp +++ b/editor/settings/editor_settings.cpp @@ -627,6 +627,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_RANGE, "interface/scene_tabs/maximum_width", 350, "0,9999,1", PROPERTY_USAGE_DEFAULT) _initial_set("interface/scene_tabs/show_script_button", false, true); _initial_set("interface/scene_tabs/restore_scenes_on_load", true, true); + EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "interface/scene_tabs/auto_select_current_scene_file", false, ""); // Multi Window EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "interface/multi_window/enable", true, "");