public void OnPointerUp(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left || moving) { return; } dragging = false; if (newDropZones.Count > 0 && newDropZones[0] != dropZone) { if (dropZone != null) { dropZone.OnItemRemove(this); connectedItems.ForEach(i => dropZone.OnItemRemove(i)); } OnDrop(newDropZones[0]); newDropZones.Clear(); } else { if (dropZone != null) { dropZone.OnDragFinish(this); } } MoveTo(homePos); }
void OnMouseUp() { dragging = false; // Check if touching any drop zones (that are not the current one) if (newDropZones.Count > 0 && newDropZones[0] != dropZone) { if (dropZone != null) { // Remove this and connected items from current drop zone dropZone.OnItemRemove(this); connectedItems.ForEach(i => dropZone.OnItemRemove(i)); } // Set new drop zone OnDrop(newDropZones[0]); newDropZones.Clear(); } else { // Notify current drop zone there has been no change if (dropZone != null) { dropZone.OnDragFinish(this); } } MoveTo(homePos); }
void OnMouseUp() { dragging = false; // if the item is in a dropzone, drop the item into it if (inDropZone) { MoveTo(homePos); } // otherwise, move the item back to its original position linearly else { endPosition = transform.position; float ratio = moveTimer / moveSeconds; transform.position = Vector3.Lerp(startPosition, endPosition, ratio); moveTimer = 0; } if (newDropZones.Count > 0) { if (dropZone != null) { dropZone.OnItemRemove(this); } newDropZones[0].OnDrop(this); dropZone = newDropZones[0]; newDropZones.Clear(); } else { if (dropZone != null) { dropZone.OnDragFinish(this); } } // move the player back to home position MoveTo(homePos); }