mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-28 06:37:11 +01:00
Fix checking if script is attached to any node belonging to scene
(cherry picked from commit 7f7966e10aa6b193012a36751dfc9f8c570b8659)
This commit is contained in:
parent
90a8cad6ed
commit
16b4bc25e9
@ -1510,16 +1510,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) {
|
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) {
|
// Check scripts only for the nodes belonging to the edited scene.
|
||||||
return nullptr;
|
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) {
|
||||||
Ref<Script> scr = p_current_node->get_script();
|
return p_current_node;
|
||||||
|
}
|
||||||
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++) {
|
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);
|
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
|
||||||
if (n) {
|
if (n) {
|
||||||
|
Loading…
Reference in New Issue
Block a user