From 63f35d24c6d852885adb37948b908820f70271c7 Mon Sep 17 00:00:00 2001 From: Jummit Date: Wed, 18 May 2022 12:19:56 +0200 Subject: [PATCH] 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. (cherry picked from commit 1101f6c660feec732af14257f6f9fa26a17364e1) --- editor/plugins/script_text_editor.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 8905f529402..f1b5c4506e6 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1563,7 +1563,12 @@ 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); + } Vector segments = path.split("/"); for (int j = 0; j < segments.size(); j++) { if (!segments[j].is_valid_identifier()) { @@ -1591,7 +1596,12 @@ 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); + } Vector segments = path.split("/"); for (int j = 0; j < segments.size(); j++) { if (!segments[j].is_valid_identifier()) {