IEnumerator SetupSellMenuSlots()
        {
            yield return(null);

            int     slotCount        = itemSlots.Count;
            int     currentSlot      = 0;
            bool    isInventoryEmpty = true;
            Vector2 oldMenuPosition  = new Vector2(menuContent.position.x, menuContent.position.y);

            for (int i = 0; i < playerInventory.GetSize(); i++)
            {
                int itemCount = playerInventory.GetCountInSlot(i);
                if (itemCount > 0)
                {
                    isInventoryEmpty = false;
                    InventoryItem  item      = playerInventory.GetItemInSlot(i);
                    ItemMenuSlotUI slotUI    = GetSlotUI(slotCount, currentSlot);
                    float          sellValue = item.GetValue() / 2f;

                    slotUI.SlotSetup("Sell", item.GetIcon(), item.GetDisplayName(),
                                     sellValue, itemCount, 10f);

                    itemSlotButtons[currentSlot].onClick.RemoveAllListeners();
                    itemSlotButtons[currentSlot].onClick.AddListener(() => itemInfoDescription.SetItemInfo(item));

                    for (int j = 0; j < slotActionButtons[currentSlot].Length; j++)
                    {
                        int inventorySlot  = i;
                        int btnIndex       = slotUI.GetActionButtonCount(j);
                        int itemCountDelta = 0;
                        slotActionButtons[currentSlot][j].onClick.RemoveAllListeners();
                        slotActionButtons[currentSlot][j].onClick.AddListener(() =>
                        {
                            itemCountDelta = SellItem(inventorySlot, btnIndex);
                            slotUI.ChangeOwnedValue(-itemCountDelta);
                        });
                    }

                    currentSlot++;
                    if ((currentSlot % 10) == 0)
                    {
                        yield return(null);
                    }
                }
            }

            if (isInventoryEmpty)
            {
                slotCoroutine = StartCoroutine(ClearSlotsAfterClose());
            }
            else if (currentSlot < slotCount)
            {
                yield return(null);

                for (int i = currentSlot; i < slotCount; i++)
                {
                    menuContent.GetChild(i).gameObject.SetActive(false);
                }
            }

            // Resize content window
            int contentHeight = currentSlot * 120;

            menuContent.sizeDelta = new Vector2(menuContent.sizeDelta.x, contentHeight);
            menuContent.position  = oldMenuPosition;
        }
        IEnumerator SetupMenuSlots(int tabIndex)
        {
            yield return(null);

            int    i         = 0;
            int    slotCount = itemSlots.Count;
            string action    = tabTexts[tabIndex].text;

            foreach (var item in menuBuilderDB.GetInventoryItems(node, tabIndex))
            {
                ItemMenuSlotUI slotUI = GetSlotUI(slotCount, i);

                slotUI.SlotSetup(action, item.GetIcon(), item.GetDisplayName(),
                                 item.GetValue(), playerInventory.GetItemCount(item), 10f);

                itemSlotButtons[i].onClick.RemoveAllListeners();
                itemSlotButtons[i].onClick.AddListener(() => itemInfoDescription.SetItemInfo(item));

                // Add listener for buy/craft X buttons
                for (int j = 0; j < slotActionButtons[i].Length; j++)
                {
                    int btnIndex       = j;
                    int itemCountDelta = 0;
                    slotActionButtons[i][j].onClick.RemoveAllListeners();
                    slotActionButtons[i][j].onClick.AddListener(() =>
                    {
                        switch (action)
                        {
                        case "Buy":
                            itemCountDelta = BuyItem(item, slotUI.GetActionButtonCount(btnIndex));
                            break;

                        case "Craft":
                            CraftItem(item, slotUI.GetActionButtonCount(btnIndex), out itemCountDelta);
                            break;
                        }
                        slotUI.ChangeOwnedValue(itemCountDelta);
                    });
                }

                i++;
                if ((i % 10) == 0)
                {
                    yield return(null);
                }
            }

            if (i < slotCount)
            {
                yield return(null);

                for (int j = i; j < slotCount; j++)
                {
                    menuContent.GetChild(j).gameObject.SetActive(false);
                }
            }
            // Resize content window
            int contentHeight = i * 120;

            menuContent.sizeDelta = new Vector2(menuContent.sizeDelta.x, contentHeight);
        }