Files
Simulation/Assets/Scripts/UI/UIBottomInventory.cs
2025-05-26 18:06:25 +09:00

47 lines
1.1 KiB
C#

using UnityEngine;
using System.Collections.Generic;
using TMPro;
using UnityEngine.UI;
public class UIBottomInventory : MonoBehaviour
{
public List<GameObject> inventory = new List<GameObject>();
public Transform content;
public TMP_Text text;
Image img;
private void Awake()
{
img = GetComponent<Image>();
}
public void LoadInventory()
{
for (int i = 0; i < content.childCount; i++)
{
GameObject obj = content.GetChild(i).gameObject;
Destroy(obj);
}
for (int i = 0; i < inventory.Count; i++)
{
GameObject prefab = inventory[i];
Instantiate(prefab, content);
}
}
public void RemoveInventory()
{
for (int i = 0; i < content.childCount; i++)
{
GameObject obj = content.GetChild(i).gameObject;
Destroy(obj);
}
}
public void OnSelect()
{
img.color = Color.red;
text.color = Color.white;
}
public void OnDeselect()
{
img.color = Color.white;
text.color = Color.black;
}
}