public void OnDrop(PointerEventData data) { if (DragAndDropItem_Training.icon != null) { if (DragAndDropItem_Training.icon.activeSelf == true) // If icon inactive do not need to drop item in cell { DragAndDropItem_Training item = DragAndDropItem_Training.draggedItem; DragAndDropCell_Training sourceCell = DragAndDropItem_Training.sourceCell; if ((item != null) && (sourceCell != this)) { switch (sourceCell.cellType) // Check source cell's type { case CellType.UnlimitedSource: string itemName = item.name; int itemnum = item.IndexNum; item = Instantiate(item); // Clone item from source cell item.name = itemName; item.IndexNum = itemnum; break; default: // Nothing to do break; } switch (cellType) // Check this cell's type { case CellType.Swap: DragAndDropItem_Training currentItem = GetComponentInChildren <DragAndDropItem_Training>(); switch (sourceCell.cellType) { case CellType.Swap: SwapItems(sourceCell, this); // Swap items between cells break; default: PlaceItem(item.gameObject); // Place dropped item in this cell break; } break; case CellType.DropOnly: PlaceItem(item.gameObject); // Place dropped item in this cell break; default: //nothing to do. break; } } if (item.GetComponentInParent <DragAndDropCell_Training>() == null) // If item have no cell after drop { Destroy(item.gameObject); // Destroy it } TrainingManager.TMInstance.DragEndAction(sourceCell.GetCellNumber(), this.GetCellNumber(), item.IndexNum); } } }
public void OnEndDrag(PointerEventData eventData) { eventData.Reset(); if (icon != null) { Destroy(icon); // Destroy icon on item drop } MakeVisible(true); // Make item visible in cell if (OnItemDragEndEvent != null) { OnItemDragEndEvent(this); // Notify all cells about item drag end } //빈 공간에 드래그 앤 드롭 했을시 if (eventData.pointerCurrentRaycast.gameObject.tag != "SkillPanel" && sourceCell.cellType == DragAndDropCell_Training.CellType.Swap) { sourceCell.RemoveItem(); TrainingManager.TMInstance.DragEndAction(sourceCell.GetCellNumber(), null, this.IndexNum); } draggedItem = null; icon = null; sourceCell = null; }