Text asset / TextMeshPro

Hope this is the right place to ask :slight_smile:

I dropped a .txt file into my assets to create a text asset.
I have created a TMP(UGI) GameObject under a Canvas.
Is there a way to set the text in the new text asset to the TMP-UGI GameObject so the text displays onscreen.
I am not sure how to reference this text asset.
All attempts so far result in the default “New Text” showing on the screen when I press play.
Thanks :slight_smile:

5305488--533106--upload_2019-12-21_14-48-44.png

Danny

I’m not sure if I understand correctly an I haven’t tested this piece of code but try something like this:

  1. put the text file in a folder named “Resources”
  2. load the text file in to some script memory
    TextAsset textFile = Resources.Load("fileName") as TextAsset;
  3. Assign the textFile to TMP text element
    yourTMPTextElement.text = textFile.text;

Thanks so much NanushTol :slight_smile:

That loaded the resource; I am still trying to figure out how I want to implement the text…
I appreciate your reply.

1 Like