Skip to content

Commit

Permalink
Merge pull request #62692 from Nolkaloid/typesafe-nodepath-dnd
Browse files Browse the repository at this point in the history
Fix drag'n drop type checking for NodePaths
  • Loading branch information
akien-mga authored Jul 4, 2022
2 parents 344b427 + 31745a8 commit 100d223
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3175,7 +3175,20 @@ bool EditorPropertyNodePath::is_drop_valid(const Dictionary &p_drag_data) const
return false;
}
Array nodes = p_drag_data["nodes"];
return nodes.size() == 1;
if (nodes.size() != 1) {
return false;
}

Node *dropped_node = get_tree()->get_edited_scene_root()->get_node(nodes[0]);
ERR_FAIL_NULL_V(dropped_node, false);

for (const StringName &E : valid_types) {
if (dropped_node->is_class(E)) {
return true;
}
}

return false;
}

void EditorPropertyNodePath::update_property() {
Expand Down

0 comments on commit 100d223

Please sign in to comment.