You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-31 18:41:20 +00:00
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.
This commit is contained in:
@@ -614,7 +614,8 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
|
||||
ERR_FAIL_NULL_V_MSG(dropped_node, false, "Could not get the dropped node by its path.");
|
||||
|
||||
if (allowed_type != "NodePath") {
|
||||
if (!ClassDB::is_parent_class(dropped_node->get_class_name(), allowed_type)) {
|
||||
if (!ClassDB::is_parent_class(dropped_node->get_class_name(), allowed_type) &&
|
||||
!EditorNode::get_singleton()->is_object_of_custom_type(dropped_node, allowed_type)) {
|
||||
// Fail if one of the nodes is not of allowed type.
|
||||
return false;
|
||||
}
|
||||
@@ -625,7 +626,8 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
|
||||
if (!allowed_subtype_array.has(dropped_node->get_class_name())) {
|
||||
// The dropped node type was not found in the allowed subtype array, we must check if it inherits one of them.
|
||||
for (const String &ast : allowed_subtype_array) {
|
||||
if (ClassDB::is_parent_class(dropped_node->get_class_name(), ast)) {
|
||||
if (ClassDB::is_parent_class(dropped_node->get_class_name(), ast) ||
|
||||
EditorNode::get_singleton()->is_object_of_custom_type(dropped_node, ast)) {
|
||||
is_drop_allowed = true;
|
||||
break;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user