Another hard fought day against my Inventory and lost again. Tomorrow I will reach out see where I went wrong. I cant get this inventory system to instantiate anything for shit. Cant even fully understand where the Instantiation happens without the word instantiate. All my code is running but being blocked somehow not recognizing the UI and putting objects into it.
{
Inventory inventory;
public GameObject inventoryUI;
public Transform itemsParent;
InventorySot[] slots;
// Start is called before the first frame update
void Start()
{
inventory = Inventory.instance;
inventory.onItemChangedCallback += UpdateUI;
slots = itemsParent.GetComponentsInChildren<InventorySot>(true);
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Inventory"))
{
inventoryUI.SetActive (!inventoryUI.activeSelf);
}
}
public void UpdateUI()
{
Debug.LogWarning("Updating UI");
for (int i = 0; i < slots.Length; i++)
{
if (i < inventory.items.Count)
{
slots[i].AddItem(inventory.items[i]);
}
else
{
slots[i].ClearSlot();
}
}
}
I believe this is the Instantiation part and that the flaw lies within however I have no clue. I can Say that the Debug .Log("Upadating UI") is not getting tripped at all.
Any help would help would be good as The inventory is critical to my Game working properly.
Till tomorrow