Repository: godotengine/godot
File: editor/plugins/node_3d_editor_plugin.cpp (C++)

Code before:
						continue;
					}
					Ref<PackedScene> scn = res;
					Ref<Material> mat = res;
					Ref<Texture2D> tex = res;
					if (scn.is_valid()) {
						Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
						if (!instantiated_scene) {
							continue;
						}
						memdelete(instantiated_scene);
					} else if (mat.is_valid()) {
						Ref<BaseMaterial3D> base_mat = res;
						Ref<ShaderMaterial> shader_mat = res;

						if (base_mat.is_null() && !shader_mat.is_null()) {
							break;
						}

						editor->set_preview_material(mat);
						break;
					} else if (tex.is_valid()) {
						Ref<StandardMaterial3D> new_mat = memnew(StandardMaterial3D);
						new_mat->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, tex);

						editor->set_preview_material(new_mat);
						break;
					} else {
						continue;
					}
					can_instantiate = true;
					break;
				}
			}
			if (can_instantiate) {
				_create_preview_node(files);
			}
		}
	} else {
		if (preview_node->is_inside_tree()) {
			can_instantiate = true;
		}
	}

	if (can_instantiate) {
		Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point));
		preview_node->set_global_transform(global_transform);
		return true;
	}

	if (editor->get_preview_material().is_valid()) {

Review comment (suggestion):
This is `can_drop_data`, AFAIK it's only supported to check if the selected files contain anything that can be used as a result of drag and drop.

Code after:
		}
	}

	if (instantiated_scene == nullptr) {
		return false;
	}

	if (!EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path().is_empty()) { // cyclical instancing
		if (_cyclical_dependency_exists(EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path(), instantiated_scene)) {
			memdelete(instantiated_scene);
			return false;
		}
	}

	if (scene != nullptr) {
		instantiated_scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(path));
	}

	editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene, true);
	editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_owner", EditorNode::get_singleton()->get_edited_scene());
	editor_data->get_undo_redo().add_do_reference(instantiated_scene);
	editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instantiated_scene);

	String new_name = parent->validate_child_name(instantiated_scene);
	EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
	editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", EditorNode::get_singleton()->get_edited_scene()->get_path_to(parent), path, new_name);
	editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(EditorNode::get_singleton()->get_edited_scene()->get_path_to(parent)) + "/" + new_name));

	Node3D *node3d = Object::cast_to<Node3D>(instantiated_scene);
	if (node3d) {
		Transform3D global_transform;
		Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
		if (parent_node3d) {
			global_transform = parent_node3d->get_global_gizmo_transform();
		}

		global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
		global_transform.basis *= node3d->get_transform().basis;

		editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_global_transform", global_transform);
	}

	return true;
}

void Node3DEditorViewport::_perform_drop_data() {
	if (spatial_editor->get_preview_material_target().is_valid()) {
		GeometryInstance3D *geometry_instance = Object::cast_to<GeometryInstance3D>(ObjectDB::get_instance(spatial_editor->get_preview_material_target()));
		MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(spatial_editor->get_preview_material_target()));
		if (mesh_instance && spatial_editor->get_preview_material_surface() != -1) {
			editor_data->get_undo_redo().create_action(vformat(TTR("Set Surface %d Override Material"), spatial_editor->get_preview_material_surface()));