浏览代码

Script Editor: Don't switch to 2D/3D viewports when selecting nodes

Selecting nodes in the Scene dock automatically switches to the relevant 2D
or 3D viewport. This behavior can be annoying while using the Script Editor
and wanting to inspect node properties, so it's now disabled by default when
the Script Editor is active.

This new behavior can be changed back to the previous auto-switching using
the `text_editor/navigation/stay_in_script_editor_on_node_selected` editor
setting.

(cherry picked from commit c4433c37932aca14b45e76a0b3498561532a0055)
Alfred R. Baudisch 3 年之前
父节点
当前提交
f00ee23b7a
共有 2 个文件被更改,包括 5 次插入0 次删除
  1. 4 0
      editor/editor_node.cpp
  2. 1 0
      editor/editor_settings.cpp

+ 4 - 0
editor/editor_node.cpp

@@ -2028,6 +2028,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
 	Object *prev_inspected_object = get_inspector()->get_edited_object();
 	Object *prev_inspected_object = get_inspector()->get_edited_object();
 
 
 	bool disable_folding = bool(EDITOR_GET("interface/inspector/disable_folding"));
 	bool disable_folding = bool(EDITOR_GET("interface/inspector/disable_folding"));
+	bool stay_in_script_editor_on_node_selected = bool(EDITOR_GET("text_editor/navigation/stay_in_script_editor_on_node_selected"));
 	bool is_resource = current_obj->is_class("Resource");
 	bool is_resource = current_obj->is_class("Resource");
 	bool is_node = current_obj->is_class("Node");
 	bool is_node = current_obj->is_class("Node");
 
 
@@ -2066,6 +2067,9 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
 			node_dock->set_node(current_node);
 			node_dock->set_node(current_node);
 			scene_tree_dock->set_selected(current_node);
 			scene_tree_dock->set_selected(current_node);
 			inspector_dock->update(current_node);
 			inspector_dock->update(current_node);
+			if (!inspector_only) {
+				inspector_only = stay_in_script_editor_on_node_selected && ScriptEditor::get_singleton()->is_visible_in_tree();
+			}
 		} else {
 		} else {
 			node_dock->set_node(nullptr);
 			node_dock->set_node(nullptr);
 			scene_tree_dock->set_selected(nullptr);
 			scene_tree_dock->set_selected(nullptr);

+ 1 - 0
editor/editor_settings.cpp

@@ -439,6 +439,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
 	hints["text_editor/navigation/minimap_width"] = PropertyInfo(Variant::INT, "text_editor/navigation/minimap_width", PROPERTY_HINT_RANGE, "50,250,1");
 	hints["text_editor/navigation/minimap_width"] = PropertyInfo(Variant::INT, "text_editor/navigation/minimap_width", PROPERTY_HINT_RANGE, "50,250,1");
 	_initial_set("text_editor/navigation/mouse_extra_buttons_navigate_history", true);
 	_initial_set("text_editor/navigation/mouse_extra_buttons_navigate_history", true);
 	_initial_set("text_editor/navigation/drag_and_drop_selection", true);
 	_initial_set("text_editor/navigation/drag_and_drop_selection", true);
+	_initial_set("text_editor/navigation/stay_in_script_editor_on_node_selected", true);
 
 
 	// Appearance
 	// Appearance
 	_initial_set("text_editor/appearance/show_line_numbers", true);
 	_initial_set("text_editor/appearance/show_line_numbers", true);