using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class InventoryUI : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
private Inventory inventory;
|
|
|
|
[SerializeField]
|
|
private BagItem ItemPrefab;
|
|
|
|
[SerializeField]
|
|
private Transform Parent;
|
|
|
|
private void Start()
|
|
{
|
|
UpdateUI();
|
|
}
|
|
|
|
[ContextMenu("Update UI")]
|
|
public void UpdateUI()
|
|
{
|
|
foreach(Transform child in Parent)
|
|
Destroy(child.gameObject);
|
|
|
|
foreach (Inventory.Data data in inventory.BagItems)
|
|
{
|
|
BagItem item = Instantiate(ItemPrefab.gameObject, Parent).GetComponent<BagItem>();
|
|
item.Initialise(data);
|
|
}
|
|
}
|
|
|
|
|
|
}
|