From d480073228fa845c95d683b1cddb99ff9d41b11b Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 29 Jul 2022 19:36:33 +0200 Subject: [PATCH] Ported: Use % when dropping unique scene nodes into script This expands uppon #60708, using `get_node("%NodeName")` for nodes that have a unique scene name to avoid having to change the onready statements when the paths of the nodes change. - Jummit https://github.com/godotengine/godot/commit/63f35d24c6d852885adb37948b908820f70271c7 --- editor/plugins/script_text_editor.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 3d2a3dc57..c58cad535 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -30,31 +30,31 @@ #include "script_text_editor.h" -#include "core/math/expression.h" -#include "core/os/input.h" -#include "core/os/keyboard.h" -#include "core/project_settings.h" -#include "editor/editor_node.h" -#include "editor/editor_scale.h" -#include "editor/editor_settings.h" -#include "editor/script_editor_debugger.h" #include "core/array.h" #include "core/class_db.h" #include "core/dictionary.h" #include "core/error_list.h" #include "core/error_macros.h" #include "core/io/resource_loader.h" +#include "core/math/expression.h" #include "core/math/math_defs.h" #include "core/math/transform_2d.h" #include "core/node_path.h" #include "core/os/file_access.h" +#include "core/os/input.h" #include "core/os/input_event.h" +#include "core/os/keyboard.h" #include "core/os/memory.h" +#include "core/project_settings.h" #include "core/script_language.h" #include "core/set.h" #include "core/string_name.h" #include "core/typedefs.h" +#include "editor/editor_node.h" +#include "editor/editor_scale.h" +#include "editor/editor_settings.h" #include "editor/plugins/script_editor_plugin.h" +#include "editor/script_editor_debugger.h" #include "scene/gui/box_container.h" #include "scene/gui/color_picker.h" #include "scene/gui/control.h" @@ -1595,7 +1595,13 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data continue; } - String path = sn->get_path_to(node); + String path; + if (node->is_unique_name_in_owner()) { + path = "%" + node->get_name(); + } else { + path = sn->get_path_to(node); + } + text_to_drop += "\"" + path.c_escape() + "\""; }