Martin j
Martin j

Reputation: 521

How to display the full list on scene in unity

  1. 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;
    }  
    
  2. Items is my List

  3. DisplayListText is the text i created on the canvas

  4. when i run this code i am able to display only one name.

  5. how to display all the names from the List to the scene.

Upvotes: 0

Views: 2095

Answers (1)

Ian H.
Ian H.

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

Related Questions