인벤토리/퀵슬롯 시스템 개발
This commit is contained in:
41
Assets/Scripts/Player/InventorySlotUI.cs
Normal file
41
Assets/Scripts/Player/InventorySlotUI.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class InventorySlotUI : MonoBehaviour
|
||||
{
|
||||
[Header("UI Elements")]
|
||||
[SerializeField] private Image iconImage;
|
||||
[SerializeField] private TextMeshProUGUI amountText;
|
||||
[SerializeField] private GameObject selectionHighlight;
|
||||
|
||||
// 슬롯의 내용을 갱신하는 함수
|
||||
public void UpdateView(int itemID, int amount)
|
||||
{
|
||||
// 빈 슬롯 처리 (ID가 -1이거나 개수가 0인 경우)
|
||||
if (itemID == -1 || amount <= 0)
|
||||
{
|
||||
iconImage.enabled = false;
|
||||
amountText.text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 싱글톤 데이터베이스에서 아이템 정보 가져오기
|
||||
var itemData = ItemDatabase.Instance.GetItemByID(itemID);
|
||||
|
||||
if (itemData != null)
|
||||
{
|
||||
iconImage.sprite = itemData.icon;
|
||||
iconImage.enabled = true;
|
||||
amountText.text = amount.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 선택 하이라이트 표시/숨김 (나중에 1~5번 키 입력 시 사용)
|
||||
public void SetSelection(bool isSelected)
|
||||
{
|
||||
if (selectionHighlight != null)
|
||||
selectionHighlight.SetActive(isSelected);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user