G
G
GORA42021-02-25 06:18:46
Unity
GORA4, 2021-02-25 06:18:46

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

2 answer(s)
G
GORA4, 2021-03-03
@GORA4

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()
        {

        }
    }
}

R
ReyGrau, 2021-02-28
@ReyGrau

What is the problem with using the standard c# read and write classes ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question