I'm working on an inventory system and for some reason it's not updating the slots. I "pick" a item from other layout, set the key "PickedItem" in a Dictionary as the picked item, then I go back to the inventory and call a while expression to check the next empty slot (the inventory is in an array) and add this picked item there.
But the problem is that it's not adding the item properly to the first empty slot. Actually it's not adding anywhere, it stays as the "PickedItem", the "PickedItem" slot never empties and the slots remains as 0.
What is strange is that for some miliseconds, it works as it should: 0 for picked item, 2 in the slot 1 (uncommon medicine herb code), 0 in the slot 2 and slot 3 as well. But after this miliseconds, it gets back to the wrong structure showed bellow on the output image.
So: what am I doing wrong!?
Thank you so much for your time and for helping me!!! Really appreciate it :)
Here is my code:
Here is my inventory array:
Here is my item list dictionary: (used to call the picked item code into the slot)
Here is the Inventory Layout (dummy texts on the bottom to test it):
Here is the output from the code: