Answer the question
In order to leave comments, you need to log in
How to display text from txt file in UI Unity?
Good afternoon.
I plan to upload information from the mind map to Dropbox in the form of .txt and download it to Unity for display in the UI.
The second day I'm trying to figure out the scripts, I tried a lot of things, as a result, the text from the "Assets\Resources\text.txt" folder is not loaded, I'm silent about Dropbox.
How best to implement? Where to dig? Maybe you have something similar in your bins?
I will be glad for any help.
Answer the question
In order to leave comments, you need to log in
Problem solved.
using UnityEngine;
using System.IO;
using TMPro;
using System;
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 + Environment.NewLine;
}
void Update()
{
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question