using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Content : MonoBehaviour
{
public GameObject slotPrefab;
void Start()
{
InventorySystem.Instance(jotain tähän) += OnUpdateInventory;
}
private void OnUpdateInventory()
{
foreach(Transform t in transform)
{
Destroy(t.gameObject);
}
DrawInventory();
}
public void DrawInventory()
{
foreach(Item item in InventorySystem.Instance.Inventory)
{
AddInventorySlot(item);
}
}
public void AddInventorySlot(Item item)
{
GameObject obj = Instantiate(slotPrefab);
obj.transform.SetParent(transform, false);
Slot slot = obj.GetComponent<Slot>();
slot.Set(item);
}
}