public static bool TryAddItem(DragDropItem item, DragDropTarget target) { if (item.attachedTarget != null) { return(false); } if (!IsChannelMatch(target, item)) { return(false); } if (target.currentItemCount >= target.maxItemCount) { return(false); } DragDropEventData eventData = new DragDropEventData(); eventData.Reset(); eventData.external = true; eventData.target = target; eventData.item = item; target.OnItemEnter(eventData); item.OnItemEnter(eventData); target.OnItemAttach(eventData); item.OnItemAttach(eventData); return(true); }
void ReplaceDropTarget(DragDropTarget oldTarget, DragDropTarget newTarget) { if (oldTarget == newTarget) { return; } if (oldTarget) { oldTarget.OnItemExit(DragDropEventData.current); OnItemExit(DragDropEventData.current); } DragDropEventData.current.target = newTarget; if (newTarget) { newTarget.OnItemEnter(DragDropEventData.current); OnItemEnter(DragDropEventData.current); } }