Table of Contents

Interface IDraggable<T>

Contract for a draggable UI item that carries data of type T. Implement this interface (via DraggableItem<T>) to participate in drag-and-drop interactions with DropZone<T>.

public interface IDraggable<T> where T : class

Type Parameters

T

The payload type associated with this draggable item.

Methods

CanReturnToOriginalPosition()

Returns true if this item should snap back to its original position after an unsuccessful drop.

bool CanReturnToOriginalPosition()

Returns

bool

CanSwapWith(IDraggable<T>)

Returns true if this item is allowed to swap data with other.

bool CanSwapWith(IDraggable<T> other)

Parameters

other IDraggable<T>

Returns

bool

GetData()

Returns the data payload carried by this draggable item.

T GetData()

Returns

T

GetTransform()

Returns the Transform of the draggable GameObject.

Transform GetTransform()

Returns

Transform

OnDragEnded(bool)

Called by the drag system when a drag operation ends.

void OnDragEnded(bool wasDropped)

Parameters

wasDropped bool

true if the item was dropped onto a valid DropZone<T>.

OnDragStarted()

Called by the drag system when a drag operation begins.

void OnDragStarted()

SetData(T)

Assigns a new data payload to this draggable item.

void SetData(T data)

Parameters

data T

SwapWith(IDraggable<T>)

Performs the data swap between this item and other.

void SwapWith(IDraggable<T> other)

Parameters

other IDraggable<T>