Skip to content

Commit 909d236

Browse files
committed
Allow dragging custom node types onto array property editor
For example, an Array[MyScript] property now accepts any node with the script MyScript on it. This works for Node and NodePath arrays alike, and also with the @export_node_path annotation.
1 parent b1eb019 commit 909d236

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

editor/editor_properties_array_dict.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
616616
ERR_FAIL_NULL_V_MSG(dropped_node, false, "Could not get the dropped node by its path.");
617617

618618
if (allowed_type != "NodePath") {
619-
if (!ClassDB::is_parent_class(dropped_node->get_class_name(), allowed_type)) {
619+
if (!ClassDB::is_parent_class(dropped_node->get_class_name(), allowed_type) &&
620+
!EditorNode::get_singleton()->is_object_of_custom_type(dropped_node, allowed_type)) {
620621
// Fail if one of the nodes is not of allowed type.
621622
return false;
622623
}
@@ -627,7 +628,8 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
627628
if (!allowed_subtype_array.has(dropped_node->get_class_name())) {
628629
// The dropped node type was not found in the allowed subtype array, we must check if it inherits one of them.
629630
for (const String &ast : allowed_subtype_array) {
630-
if (ClassDB::is_parent_class(dropped_node->get_class_name(), ast)) {
631+
if (ClassDB::is_parent_class(dropped_node->get_class_name(), ast) ||
632+
EditorNode::get_singleton()->is_object_of_custom_type(dropped_node, ast)) {
631633
is_drop_allowed = true;
632634
break;
633635
} else {

0 commit comments

Comments
 (0)