43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
// This is the container for the inventory UI slots
|
|
public class InventorySlotUI : MonoBehaviour
|
|
{
|
|
public ItemSlotUI[] slots;
|
|
ItemNameUI itemNameUI;
|
|
ItemDescriptionUI itemDescriptionUI;
|
|
|
|
private void Start()
|
|
{
|
|
slots = GetComponentsInChildren<ItemSlotUI>();
|
|
itemNameUI = GetComponentInChildren<ItemNameUI>();
|
|
itemDescriptionUI = GetComponentInChildren<ItemDescriptionUI>();
|
|
}
|
|
|
|
public void ShowSlots()
|
|
{
|
|
gameObject.SetActive(true);
|
|
|
|
for (int i = 0; i < slots.Length; i++)
|
|
{
|
|
if (GameManager.Instance.Inventory.itemSlots[i] != null)
|
|
{
|
|
slots[i].SetItem(GameManager.Instance.Inventory.itemSlots[i]);
|
|
}
|
|
}
|
|
|
|
foreach (ItemSlotUI slot in slots)
|
|
{
|
|
slot.LoadImage(itemNameUI, itemDescriptionUI);
|
|
}
|
|
}
|
|
|
|
public void HideSlots()
|
|
{
|
|
itemNameUI.nameText = "";
|
|
itemDescriptionUI.descriptionText = "";
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|