godot/demos/gui/drag_and_drop/drag_drop_script.gd

25 lines
433 B
GDScript3
Raw Normal View History

2015-03-22 15:52:47 +00:00
extends ColorPickerButton
2015-03-22 16:01:34 +00:00
#virtual function
2015-03-22 15:52:47 +00:00
func get_drag_data(pos):
2015-03-22 16:01:34 +00:00
#use another colorpicker as drag preview
2015-03-22 15:52:47 +00:00
var cpb = ColorPickerButton.new()
cpb.set_color( get_color() )
cpb.set_size(Vector2(50,50))
set_drag_preview(cpb)
#return color as drag data
return get_color()
2015-03-22 16:01:34 +00:00
#virtual function
2015-03-22 15:52:47 +00:00
func can_drop_data(pos, data):
return typeof(data)==TYPE_COLOR
2015-03-22 16:01:34 +00:00
#virtual function
2015-03-22 15:52:47 +00:00
func drop_data(pos, data):
set_color(data)