List limits element size

I have created a list for item database but even if i added a new item, list doesnt show the rest of the item except 2 elemets.

public List<Item> itemDatabase = new List<Item>();
    public Sprite[] spriteBox = new Sprite[] { };
  
    private void Awake()
    {
         AddItem(new Item("carrot", "gathered from garden", 5, 10, Item.ItemType.food, spriteBox[0]), 5, 15); //this is appear
         AddItem(new Item("potion", "made by alchemist", 10, 10, Item.ItemType.consumable, spriteBox[7]), 3); //this is appear
         AddItem(new Item("posionousPotion", "made by alchemist", 10, 10, Item.ItemType.consumable, spriteBox[7]), 0, 0, 0, 0, 3); //This item doesnt appear in the inspector.

    }

    private void AddItem(Item item,params int[] stats)
    {
        itemDatabase.Add(item);
        switch(item.itemType)
        {
            //we've set these properties here and after using item these are gonna add its properties to player stat.
            case Item.ItemType.food:
                item.health = stats[0];
                item.hunger = stats[1];
                break;
            case Item.ItemType.consumable:
                item.fastSpeed = stats[0];
                item.concentrate = stats[1];
                item.instantHealthLoss = stats[2];
                item.starving = stats[3];
                item.slowWalking = stats[4];
                break;
        }    
        
    }

I think i solved the problem. Im thinking that engine sorting the list along parameter number in the method. I have just swap the lines, in the Awake method.

Your answer doesn’t make much sense. Your issue is that for your second item you only pass a single int value to your variable argument list. However the code inside your AddItem method tries to read stats 0,1,2,3 and 4 which obviously will fail when the params array only contains a single item. Therefore that code will throw an exception and terminates the execution at this point. So your third item will never be added because the code is never reached.

Your code has to produce an index out of range exception. Why didn’t you mention that?