public class InventoryUI : MonoBehaviour
{
public Transform itemsParent;
Inventory inventory; // Our current inventory
InventorySlot[] slots;
void Start()
{
inventory = Inventory.instance;
inventory.OnItemChangedCallback += UpdateUI;
slots = GetComponentsInChildren<InventorySlot>();
}
void Update()
{
{
// Loop through all the slots
for (int i = 0; i < slots.Length; i++)
{
if (i < inventory.items.Count) // If there is an item to add
{
slots_.AddItem(inventory.items*); // Add it*_
}
else
{
// Otherwise clear the slot
slots*.ClearSlot();*
}
}
}
void UpdateUI () {
Debug.Log(“UPDATING UI”);
}
}
}