diff options
author | Jummit <jummit@web.de> | 2022-05-18 12:19:56 +0200 |
---|---|---|
committer | Jummit <jummit@web.de> | 2022-05-18 15:21:31 +0200 |
commit | 1101f6c660feec732af14257f6f9fa26a17364e1 (patch) | |
tree | 5e90c82ee60ad058411a2fb439ffb895b17c30c1 | |
parent | 5631b59e218f4883442382c097eed10ed76b3c8d (diff) |
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.
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index ee8767e6a6..9df99dcce4 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1568,7 +1568,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); + } for (const String &segment : path.split("/")) { if (!segment.is_valid_identifier()) { path = path.c_escape().quote(quote_style); @@ -1595,7 +1600,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); + } for (const String &segment : path.split("/")) { if (!segment.is_valid_identifier()) { path = path.c_escape().quote(quote_style); |