From 8fdd612ee7b3b71caa115be531952c757efdf53a Mon Sep 17 00:00:00 2001 From: SweetMe1ody <770757532@qq.com> Date: Mon, 21 Jun 2021 20:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=8C=E5=8C=85=E4=B8=AD=E7=9A=84=E6=A0=BC?= =?UTF-8?q?=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Script/InventoryScripts/Slot.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Script/InventoryScripts/Slot.cs 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; + } +}