public void addToInventory(ItemScript item) { bool found = false; foreach (ItemScript i in inventory) { if (i.itemName == item.itemName) { i.AddItem(); i.OnPickUp(); //Debug.Log("Player has item " + item.itemName +" Count: "+i.count); InventoryEvent?.Invoke(inventory); found = true; } } //Debug.Log("Adding " + item.itemName + " to inventory first time."); if (!found) { inventory.Add(item); item.AddItem(); item.OnPickUp(); InventoryEvent?.Invoke(inventory); } }