/// <summary> /// Raises the drop event. /// </summary> /// <param name="eventData">Event data.</param> public void OnDrop(PointerEventData eventData) { if (eventData.pointerPress == null) { return; } // Try getting slot base component from the selected object UISlotBase slotBase = this.ExtractSlot(eventData); // Check if we have a slot if (slotBase == null) { return; } // Determine the type of slot we are dropping here if (slotBase is UIItemSlot) { UIItemSlot itemSlot = (slotBase as UIItemSlot); // Make sure the slot we are dropping is valid and assigned if (itemSlot != null && itemSlot.IsAssigned()) { // Try finding a suitable slot to equip UIEquipSlot equipSlot = this.GetSlotByType(itemSlot.GetItemInfo().EquipType); if (equipSlot != null) { // Use the drop event to handle equip equipSlot.OnDrop(eventData); // Hide the hint this.HideHint(); // Break out of the method return; } } } }
public void OnDrop(PointerEventData eventData) { if (eventData.pointerPress == null) { return; } // Try getting slot base component from the selected object UISlotBase slotBase = eventData.pointerPress.gameObject.GetComponent <UISlotBase>(); // Check if we have a slot if (slotBase == null) { return; } // Determine the type of slot we are dropping here if (slotBase is UIItemSlot) { UIItemSlot itemSlot = (slotBase as UIItemSlot); // Make sure the slot we are dropping is valid and assigned if (itemSlot != null && itemSlot.IsAssigned()) { // Try finding a suitable slot to equip UIEquipSlot equipSlot = UIEquipSlot.GetSlotWithType(itemSlot.GetItemInfo().EquipType); if (equipSlot != null) { // Use the drop event to handle equip equipSlot.OnDrop(eventData); return; } } } }