47 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|