public void AddItem(Item item)
    {
        //Debug.Log("AddItem");
        itemList.Add(item);

        if (inventoryUI == null)
        {
            inventoryUI = InventoryUI.instance;
        }

        if (inventoryUI != null)
        {
            inventoryUI.AddItemToUI(item, GetTotalItems() - 1);
        }
        else
        {
            Debug.Log("inventoryUI is null when adding");
        }
    }
    private void Start()
    {
        inventoryUI = FindObjectOfType <InventoryUI>();
        if (inventoryUI == null)
        {
            Debug.LogError("inventoryUI is null");
        }

        // Add initial items into the bag
        int count = 0;

        foreach (Item item in itemList)
        {
            if (item != null)
            {
                inventoryUI.AddItemToUI(item, count);
                count++;
            }
        }
    }