//when something is dropped on slot public override void OnDrop(PointerEventData eventData) { ItemDragHandler itemDragHandler = eventData.pointerDrag.GetComponent <ItemDragHandler>(); if (itemDragHandler == null) { return; } //check what previous slot is & then set or swap accordingly InventorySlot inventorySlot = itemDragHandler.ItemSlotUI as InventorySlot; /*treat slot as inventory slot, check if it actually is.. * If YES, get item from slot, set, return..*/ if (inventorySlot != null) { SlotItem = inventorySlot.ItemSlot.item; slotItem.inventoryItem = inventorySlot.ItemSlot.item; return; } HotBarSlot hotBarSlot = itemDragHandler.ItemSlotUI as HotBarSlot; /*SWAP.. * if a hotbar slot is being dropped onto other hbs, store current slot item, set to new item, * THEN set item dropped to previous item*/ if (hotBarSlot != null) { HotBarItem oldItem = SlotItem; SlotItem = hotBarSlot.SlotItem; hotBarSlot.SlotItem = oldItem; return; } }
public override void OnDrop(PointerEventData eventData) { //when something is dropped on x slot, get drag handler script ItemDragHandler itemDragHandler = eventData.pointerDrag.GetComponent <ItemDragHandler>(); if (itemDragHandler == null) { return; } //if inventory slot is dropped on another inv. slot if ((itemDragHandler.ItemSlotUI as InventorySlot) != null) { inventory.Swap(itemDragHandler.ItemSlotUI.SlotIndex, SlotIndex); } //for (int i = 0; 0 < hotBarSlots.Length; i++) //{ // hotBarSlots[i].SlotItem = inventory.ItemContainer.GetSlotByIndex(i).item; //} }