GUI Menu Major Performance Issues

Hey,

I have been working on a trading system for some time and I got everything to work, but the menu is extremely laggy. The performance is about 170 FPS when I am not in the trade menu, but as soon as I open it, my frames drop to about 20 FPS and I have no clue why. I am using the exact same method of drawing these elements as in my inventory and the inventory stays at constant 170 FPS. Maybe you guys can help me somehow, I am clueless. I have tried so many things and nothing even slightly increased the frame rate.

The problem is the ShowTradeOptions() method.

    List<Item> tradeItems = new List<Item>();
    Item selectedItem = new Item();
    Rect moveRightButtonRect, moveLeftButtonRect;

    void ShowTradeOptions()
    {    
        for (int i = 0; i < availableItems.Count; i++)
        {
            GUI.Box(myItemsRects*, "", gameDatabase.inventorySkin.GetStyle("Slot"));*

GUI.DrawTexture(myItemsRects_, availableItems*.itemIcon);*_

GUI.Box(tradeItemsRects*, “”, gameDatabase.inventorySkin.GetStyle(“Slot”));*
GUI.DrawTexture(tradeItemsRects_, tradeItems*.itemIcon);
}
}*_

I am now posting an answer to my issue because I managed to fix it.

The issue was that I was trying to draw a texture that was null and Unity could not handle that properly. It does not give you an error, but it results in significant frame rate drops below the playable state.

So, I am now only setting a texture if the texture is not null.