drag_drop_script.gd 359 B

123456789101112131415161718192021
  1. extends ColorPickerButton
  2. func get_drag_data(pos):
  3. # Use another colorpicker as drag preview
  4. var cpb = ColorPickerButton.new()
  5. cpb.color = color
  6. cpb.rect_size = Vector2(50, 50)
  7. set_drag_preview(cpb)
  8. # Return color as drag data
  9. return color
  10. func can_drop_data(pos, data):
  11. return typeof(data) == TYPE_COLOR
  12. func drop_data(pos, data):
  13. color=data