Unity Load text from resources

c#, unity-game-engine

Solution

Simply use this:

TextAsset mytxtData=(TextAsset)Resources.Load("MyText");
string txt=mytxtData.text;

and you can use the `txt` string to fulfill your requirement, just make sure that `MyText.txt` is in `Assets > Resources`

Problem

I'm able to change the text of a `UILabel` (named about) with the following: ``` using UnityEngine; using System.Collections; public class about : MonoBehaviour { void Start () { UILabel lbl = GetComponent<UILabel>(); lbl.text = "Hello World!"; } } ``` However things go awry when I want to load the label text from a text file in resources (`Assets/Resources/about.txt`) ``` lbl.text = Resources.Load(Application.dataPath + "/Resources/about") as String ``` So I'm not sure where I'm going wrong, and yes I have looked here.

Original source