diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-21 18:55:18 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-21 18:55:18 +0200 |
commit | f3373e8311ccbf2004068140ab31a9e1415628f1 (patch) | |
tree | 373ba0bbe619ec7cad6a8278e9cfc5f6ce48222b /editor/plugins | |
parent | 9f2748f63ceb19d4a7734819557a1607d2d4c348 (diff) | |
parent | 7f7966e10aa6b193012a36751dfc9f8c570b8659 (diff) |
Merge pull request #66212 from kleonc/script-text-editor-fix-check-if-script-used-within-scene
`ScriptTextEditor` Fix checking if script is attached to any node belonging to scene
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 1ae4c530e8..ad07ac180b 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1487,16 +1487,17 @@ bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_ } static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { - if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) { - return nullptr; - } - - Ref<Script> scr = p_current_node->get_script(); - - if (scr.is_valid() && scr == script) { - return p_current_node; + // Check scripts only for the nodes belonging to the edited scene. + if (p_current_node == p_edited_scene || p_current_node->get_owner() == p_edited_scene) { + Ref<Script> scr = p_current_node->get_script(); + if (scr.is_valid() && scr == script) { + return p_current_node; + } } + // Traverse all children, even the ones not owned by the edited scene as they + // can still have child nodes added within the edited scene and thus owned by + // it (e.g. nodes added to subscene's root or to its editable children). for (int i = 0; i < p_current_node->get_child_count(); i++) { Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script); if (n) { |