diff --git a/Script/InventoryScripts/Slot.cs b/Script/InventoryScripts/Slot.cs new file mode 100644 index 0000000..0b42bcf --- /dev/null +++ b/Script/InventoryScripts/Slot.cs @@ -0,0 +1,33 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class Slot : MonoBehaviour +{ + public int slotIndex; // 物品在背包中的下标 + public Item slotItem; + public Image slotImage; + public Text slotNum; + public string slotInfo; + + public GameObject itemInSlot; + + public void ItemOnClicked() + { + InventoryManager.UpdateItemInfo(slotInfo); + } + + public void SetupSlot(Item item) + { + if(item == null) + { + itemInSlot.SetActive(false); + return; + } + + slotImage.sprite = item.itemImage; + slotNum.text = item.itemHeld.ToString(); + slotInfo = item.itemInfo; + } +}