draggable items

This commit is contained in:
Janis
2023-02-22 13:39:32 +01:00
parent 5773aa0af7
commit 13902bc589
6 changed files with 218 additions and 29 deletions

View File

@@ -25,7 +25,9 @@ public class InventoryUI : MonoBehaviour
for (int i = 0; i < playerInventory.maxSlots; i++)
{
slotUIList.Add(Instantiate(slotPrefab, Vector3.zero, Quaternion.identity, slotListObj.transform).GetComponent<SlotUI>());
SlotUI newSlot = Instantiate(slotPrefab, Vector3.zero, Quaternion.identity, slotListObj.transform).GetComponent<SlotUI>();
newSlot.slotIndex = i;
slotUIList.Add(newSlot);
}
}
private void UpdateSlots()
@@ -34,14 +36,9 @@ public class InventoryUI : MonoBehaviour
int i = 0;
foreach (SlotUI slotUi in slotUIList)
{
if (i < playerInventory.items.Count)
{
slotUi.SetInventoryItem(playerInventory.items[i]);
}
else
{
slotUi.SetInventoryItem(null);
}
slotUi.SetInventoryItem(playerInventory.items[i]);
i++;
}