using Assets.Scripts.Helpers;
|
using System.Collections;
|
using System.Collections.Generic;
|
using TMPro;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using static UnityEditor.Progress;
|
|
public enum ItemUIType
|
{
|
ItemNameDescription,
|
ItemDescription
|
}
|
|
public class ItemUIScript : MonoBehaviour
|
{
|
private InventorySlot inventorySlot;
|
|
public ItemUIType itemUIType;
|
|
public InventorySlot InventorySlot
|
{
|
get => inventorySlot;
|
set
|
{
|
inventorySlot = value;
|
switch (itemUIType)
|
{
|
case ItemUIType.ItemNameDescription:
|
gameObject.transform.Find("ItemName").GetComponent<TextMeshProUGUI>().text = inventorySlot.item.itemName;
|
gameObject.transform.Find("ItemQuantity").GetComponent<TextMeshProUGUI>().text = inventorySlot.quantity.ToString() + "x";
|
gameObject.transform.Find("ItemIcon").GetComponent<Image>().sprite = inventorySlot.item.itemIcon;
|
UIHelper.UpdateItemMaxCountText(gameObject.transform.Find("ItemQuantity").GetComponent<TextMeshProUGUI>(), inventorySlot.quantity, inventorySlot.item.maxStackSize);
|
break;
|
case ItemUIType.ItemDescription:
|
gameObject.transform.Find("ItemTextDescription").GetComponent<TextMeshProUGUI>().text = inventorySlot.item.itemDescription;
|
break;
|
}
|
}
|
}
|
private void OnDestroy()
|
{
|
gameObject.GetComponent<Button>()?.onClick?.RemoveAllListeners();
|
}
|
}
|