Reputation: 521
i am a beginner in unity i have a list which consist of some names. I want to display all those names in the scene. i am able to log all the names in list in the console.i need to display them on the scene
for (int i = 0; i <= Items.Count - 1; i++)
{
b = (Items[i].ToString());
DisplayListText.text = b;
}
Items is my List
DisplayListText is the text i created on the canvas
when i run this code i am able to display only one name.
how to display all the names from the List to the scene.
Upvotes: 0
Views: 2095
Reputation: 3929
You are setting the text instead of adding to it.
Change this:
DisplayListText.text = b;
to this:
DisplayListText.text += b + '\n';
Upvotes: 1