public void OnBeginDrag(PointerEventData eventData) { if (UISlot.getSlot().getItem() != null) { originalPos = Vector2.zero; this.transform.SetParent(GameManager.UIHandler.cursorLayerParent); image.raycastTarget = false; } }
public void OnEndDrag(PointerEventData eventData) { if (UISlot.getSlot().getItem() != null) { this.transform.SetParent(originalParent); transform.localPosition = originalPos; RaycastResult ray = eventData.pointerCurrentRaycast; if (ray.gameObject != null && ray.gameObject.name.Equals("ItemIcon")) { UISlot otherUISlot = ray.gameObject.GetComponent <Dragable>().UISlot; UIHandler.onDragAndDropEvent(this.UISlot.getSlot(), otherUISlot.getSlot()); } else if (ray.gameObject.name.Equals("Slot")) { } else { ItemStack item = this.UISlot.parentSlot.getItem(); this.UISlot.parentSlot.setItem(null); GameManager.getLocalPlayer().dropItem(item); } image.raycastTarget = true; } }