Jelajahi Sumber

Fix Visual Script's jump to function relative to zoom

When double-clicking on a function name the graph will now correctly jump to the function relative to the zoom ratio.

(cherry picked from commit e8a326a08fa334eb54a5a1ff09722caf90c160d8)
Nicholas Huelin 3 tahun lalu
induk
melakukan
12ca7fbfe3
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      modules/visual_script/visual_script_editor.cpp

+ 1 - 1
modules/visual_script/visual_script_editor.cpp

@@ -2550,7 +2550,7 @@ void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) {
 
 	if (gn) {
 		gn->set_selected(true);
-		Vector2 new_scroll = gn->get_offset() - graph->get_size() * 0.5 + gn->get_size() * 0.5;
+		Vector2 new_scroll = gn->get_offset() * graph->get_zoom() - graph->get_size() * 0.5 + gn->get_size() * 0.5;
 		graph->set_scroll_ofs(new_scroll);
 		script->set_function_scroll(p_func, new_scroll / EDSCALE);
 		script->set_edited(true);