Hi, I have a little problem here.
I’m making a List display system. Each element of the list can be blue, red, or empty.
I made a for loop that instantiate items with ui text according to the lenght of the list and its items inside.
`
private void DisplayInventory()
{
for (int i = 0; i < Inventory.InventoryList.Count; i++)
{
var NewItemDisplay = Instantiate(ItemDisplay);
NewItemDisplay.transform.parent = gameObject.transform;
Text ButtonText = NewItemDisplay.GetComponentInChildren<Text>();
ButtonText.text = Inventory.InventoryList*.name;*
}
}
`
as you can see it works fine: [203502-image-2023-01-02-043441250.png*|203502]
----------
But the problem here is: when one element inside the list is empty, it does this:
[203503-image-2023-01-02-044955132.png|203503]*
----------
So it seems that the empty name is breaking the loop…
Any help would be helpfull for me ! I’m a very beginner
*
*