Interface IDraggable<T>
- Namespace
- WitShells.DesignPatterns.Core
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
TThe 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
CanSwapWith(IDraggable<T>)
Returns true if this item is allowed to swap data with other.
bool CanSwapWith(IDraggable<T> other)
Parameters
otherIDraggable<T>
Returns
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
wasDroppedbooltrueif 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
dataT
SwapWith(IDraggable<T>)
Performs the data swap between this item and other.
void SwapWith(IDraggable<T> other)
Parameters
otherIDraggable<T>