I actually have this in my awake (to replace the Array declaration that was there)
slots = new List<InventorySlot> (new InventorySlot[inventorySize]);
That way the logic works and it is declared with the same “starting” size
also had to change all the slots.length with slots.count
and since its impossible to alter a list at index position, i changed the code to something like this :
InventorySlot tempslot = slots[i];
tempslot.item = InventoryItem.GetFromID(slotStrings[i].itemID);
tempslot.number = slotStrings[i].number;
slots[i] = tempslot;
As for “how I add a new slot”, I created a boolean to determine if the new item added was using a “new empty slot” (and not stackable)
if (boolNewItem)
{
// ADD NEW SLOTS WHEN PICKING UP NEW ITEMS
inventorySize++;
var newslot = new InventorySlot();
slots.Add(newslot);
}
and this added the new slot at the end of the list…
As I wrote, so far, everything works… hehe… i was extremely impressed i managed to figure all of that and make it work!