Framework/ Drag & Drop

draganddrop

Example Usage

As always, you can find this example in the Components sample.

DragAndDropManipulator

Manipulator to add to VisualElements that will start drag operation.

CSHARP

DragAndDropDemo

CSHARP

DragAndDropManipulator

DragAndDropManipulator is the base class you can inherit from to create custom Drag & Drop operations easily.

Contructors

LunaUIManager?

LunaUIManager's purpose in DragAndDropManipulator is to prevent hover audio from playing when hovering over other buttons and interactable elements while dragging an element.

When a drag operation starts, if LunaUIManager is not null, hover audio will be muted until the drag operation ends.

Public Methods

CreateDragElement

Called when drag operation starts.

Override to create the drag element, initialize the logic, and register event handlers, etc.

DisposeDragElement

Called when drag operation ends.

Override to dispose of the drag element, clean up logic, and unregister event handlers, etc.

Events

OnStart<Vector3>

First parameter is pointerPosition.

OnMove<Vector3>

First parameter is pointerPosition.

OnDrop<int, int, VisualElement>

First parameter is key.

Second parameter is the index of the drop slot where the element was dropped.

Second parameter is the drop slot where the element was dropped.

OnCancel