Achyls
Decapat
- Katılım
- 28 Haziran 2023
- Mesajlar
- 80
Daha fazla
- Sistem Özellikleri
- RTX 3060Ti, I5 12600K, 16GB RAM, 1 TB SSD
- Cinsiyet
- Erkek
- Meslek
- Öğrenci
C#:
public void MergeItems(int sourceIndex, int targetIndex)
{
Slot sourceSlot = PlayerInventory.inventorySlots[sourceIndex];
Slot targetSlot = PlayerInventory.inventorySlots[targetIndex];
// Control their items.
if (sourceSlot.item != null && targetSlot.item != null&& sourceSlot.item == targetSlot.item)
{
// merge item.
targetSlot.itemcount += sourceSlot.itemcount;
inventoryUI.UpdateUI();
Debug.Log($"Updated Target Count = {targetSlot.itemcount}");
// discharge the source slot.
sourceSlot.item = null;
sourceSlot.itemcount = 0;
sourceSlot.isFull = false;
inventoryUI.UpdateUI();
}
else.
{
Debug.Log("Items do not match or one of the slots is empty.");
}
}
Kodda eşyaları ayırabiliyor ama ayrı olan eşyalar birleşmiyor anlamadım yardımcı olabilecek var mı?