Skip to content

Commit 8dc3067

Browse files
committed
Fix resource property editor incorrectly accepting script files
See discussion on godotengine#102534. Before this fix, it was possible to drag a file `CustomResource.gd` with `class_name CustomResource` onto a property of type `CustomResource`. Of course, the intention is that only `Resource`s with the `CustomResource` script attached are accepted. (Actually accepting the script, but creating a resource from it automatically, is left as a future improvement.)
1 parent 91688fe commit 8dc3067

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

editor/editor_resource_picker.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,11 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const {
686686
return true;
687687
}
688688

689-
StringName custom_class = EditorNode::get_singleton()->get_object_custom_type_name(res.ptr());
690-
if (_is_type_valid(custom_class, allowed_types)) {
691-
return true;
689+
if (res->get_script()) {
690+
StringName custom_class = EditorNode::get_singleton()->get_object_custom_type_name(res->get_script());
691+
if (_is_type_valid(custom_class, allowed_types)) {
692+
return true;
693+
}
692694
}
693695
}
694696

0 commit comments

Comments
 (0)