Reputation: 85
How can I take text from array and put it by order in my text. For now my text only shows last item in array.
Here is the code:
void Start()
{
this.gameObject.GetComponent<MeshRenderer>().sortingLayerName = "Foreground";
textMesh = GetComponent<TextMeshPro>();
for (int i = 0; i < slova.Length; i++)
{
string value = slova[i];
textMesh.text = value;
int random = Random.Range(0, slova.Length);
}
}
Upvotes: 0
Views: 64
Reputation: 350
You should use a linq instruction like
void Start()
{
this.gameObject.GetComponent<MeshRenderer>().sortingLayerName = "Foreground";
textMesh = GetComponent<TextMeshPro>();
textMesh.text = string.Join(" ", slova);
}
something like this:
Upvotes: 1
Reputation: 301
I don´t know what you want to achieve. But if you want that textMesh.text should be appended with value, than you should use the following
textMesh.text += slova[i];
Upvotes: 0