Need help
What needs to be fixed in the script to display all the text from the txt file
Currently only one line is displayed
If viewed through the console, then all the text is displayed using:
Console.WriteLine("{0}:{1}",counter,Line);
I would be glad for any help.
using UnityEngine;
using System.IO;
using TMPro;
public class TextUI : MonoBehaviour
{
public TextMeshProUGUI TextMP;
void Start()
{
StreamReader sr = new StreamReader(@"C:\Users\Professional\Dropbox\SD\text.txt");
string line = "";
int counter = 0;
while ((line = sr.ReadLine()) != null)
{
counter++;
TextMP.text = counter + line;
}
void Update()
{
}
}
}