Skip to content

Components

DragSource

Marks a node as something a pointer can pick up and carry, such as an item out of a bag. Kind is matched against a Drop Target's accepted list, Preview names a node drawn under the pointer, and Disabled stops pick-ups. Goes under a Canvas.

On this page

Add it

Add component → DragSourceComponent in the Inspector, on the node that should carry it.

From a script

A script on the same node writes these fields by name. DragSourceComponent is the name to pass.

rgs
set_text("DragSourceComponent", "action", "");
set_text("DragSourceComponent", "kind", "item");
set_text("DragSourceComponent", "preview", "");
set_flag("DragSourceComponent", "disabled", false);

Fields

FieldScript nameKindDefaultWhat it does
ActionactiontextemptyReported when a drag from here ends: 1 if it landed, 0 if it came back; a slot that is also a drop target needs a different action on each end, since one action cannot tell an item arriving here from this slot's own item landing.
KindkindtextitemMatched against a drop target's accepted kinds.
PayloadpayloadtextemptyThe thing itself: an item id, a slot number, whatever the game means.
PreviewpreviewtextemptyNode to draw under the pointer while dragging.
DisableddisabledcheckboxoffWhen on, this cannot be picked up, so a press on it is only a press.