diff --git a/addons/block_code/ui/block_canvas/block_canvas.gd b/addons/block_code/ui/block_canvas/block_canvas.gd index ffcc4b86..89436d01 100644 --- a/addons/block_code/ui/block_canvas/block_canvas.gd +++ b/addons/block_code/ui/block_canvas/block_canvas.gd @@ -2,6 +2,7 @@ extends MarginContainer const BlockCodePlugin = preload("res://addons/block_code/block_code_plugin.gd") +const BlockDefinition = preload("res://addons/block_code/code_generation/block_definition.gd") const BlockTreeUtil = preload("res://addons/block_code/ui/block_tree_util.gd") const DragManager = preload("res://addons/block_code/drag_manager/drag_manager.gd") const InstructionTree = preload("res://addons/block_code/instruction_tree/instruction_tree.gd") @@ -55,6 +56,27 @@ func _ready(): _populate_block_scenes_by_class() +func _can_drop_data(at_position: Vector2, data: Variant) -> bool: + return true + + +func _drop_data(at_position: Vector2, data: Variant) -> void: + if typeof(data) != TYPE_DICTIONARY: + return + + data = data as Dictionary + + if data.get("type") != "files": + return + + for file in data.get("files", []): + var resource = load(file) + if resource is BlockDefinition: + var block = Util.instantiate_block(resource) + add_block(block, at_position) + reconnect_block.emit(block) + + func _populate_block_scenes_by_class(): for _class in ProjectSettings.get_global_class_list(): if not _class.base.ends_with("Block"): diff --git a/addons/block_code/ui/block_canvas/block_canvas.tscn b/addons/block_code/ui/block_canvas/block_canvas.tscn index 0d3e8e4c..a7c47b59 100644 --- a/addons/block_code/ui/block_canvas/block_canvas.tscn +++ b/addons/block_code/ui/block_canvas/block_canvas.tscn @@ -15,10 +15,12 @@ script = ExtResource("1_tk8h2") [node name="Panel" type="Panel" parent="."] layout_mode = 2 +mouse_filter = 2 [node name="WindowContainer" type="Control" parent="."] clip_contents = true layout_mode = 2 +mouse_filter = 2 [node name="Window" type="Control" parent="WindowContainer"] unique_name_in_owner = true