public void OnEndDrag(PointerEventData eventData) { image.color = Color.white; Cursor.visible = true; image.raycastTarget = true; drag = false; inventory.DrawRegularSlotsColors(); var eventDataRaycast = eventData.pointerCurrentRaycast; if (eventDataRaycast.gameObject == null && inventory.dragItemOutsideToDrop) { inventory.DropItem(this); return; } if (eventDataRaycast.gameObject != null && item != null && item.stackable == true && eventDataRaycast.gameObject.GetComponent <InventoryItem>() != null && eventDataRaycast.gameObject.GetComponent <InventoryItem>().item.id == item.id && eventDataRaycast.gameObject.GetComponent <InventoryItem>().item.stackSize + item.stackSize <= item.maxStackSize) { eventDataRaycast.gameObject.GetComponent <InventoryItem>().item.stackSize += item.stackSize; inventory.RemoveItem(this); Destroy(gameObject); return; } if (eventDataRaycast.gameObject != null && eventDataRaycast.gameObject.GetComponent <GridSlot>()) { var slot = eventData.pointerCurrentRaycast.gameObject.GetComponent <GridSlot>(); if (inventory.CheckFreeSpaceAtSlot(CalculateShiftedAxes().x, CalculateShiftedAxes().y, width, height) && slot.free && slot.equipmentPanel == null) { transform.SetParent(slot.transform.parent); finalPosition = inventory.FindSlotByIndex(CalculateShiftedAxes().x, CalculateShiftedAxes().y).GetComponent <RectTransform>().anchoredPosition; x = CalculateShiftedAxes().x; y = CalculateShiftedAxes().y; inventory.MarkSlots(CalculateShiftedAxes().x, CalculateShiftedAxes().y, width, height, false); } else if (inventory.CheckFreeSpaceAtSlot(CalculateShiftedAxes().x, CalculateShiftedAxes().y, width, height) && slot.free && slot.equipmentPanel != null && slot.equipmentPanel.allowedItemType == item.type) { transform.SetParent(slot.transform.parent); finalPosition = inventory.FindSlotByIndex(CalculateShiftedAxes().x, CalculateShiftedAxes().y).GetComponent <RectTransform>().anchoredPosition; x = CalculateShiftedAxes().x; y = CalculateShiftedAxes().y; slot.equipmentPanel.equipedItem = item; inventory.MarkSlots(CalculateShiftedAxes().x, CalculateShiftedAxes().y, width, height, false); } else { finalPosition = lastPosition; inventory.MarkSlots(x, y, width, height, false); } } else { finalPosition = lastPosition; inventory.MarkSlots(x, y, width, height, false); } }