How to update Inventory slots dynamically?

So I want to update the slots dynamically depending on the type of bad the player carries. I tried the below method but failed. Basically I want to update the slots in “Update” instead of “Awake”

private void Update()
{
playerInventory = Inventory.GetPlayerInventory();
playerInventory.inventoryUpdated += Redraw;
}

Whatever you do, don’t put an InventoryUpdated event in Update, as this will destroy and redraw the inventory UI every frame and the Garbage Collector will eventually take a heavy toll on your code.

Whenever you make a change to Inventory (AddItems, RemoveItems, etc), inventoryUpdated is called automatically.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms