Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved I want to change the text of TextMeshPro with c#.

Discussion in 'Scripting' started by unitsume, Nov 18, 2022.

  1. unitsume

    unitsume

    Joined:
    Oct 7, 2022
    Posts:
    31
    Hello.
    I want to change the text of TextMeshPro with c#.
    However, I searched Google for how to change it, but I can't change it.
    How can I change TextMeshPro text in C#?

    My execution environment
    Unity Editor 2021.3.11f1
    TextMeshPro 3.0.6

    My settings now
    [Hierarchy] > [+] > [3D Object] > [Text-TextMeshPro]
    I Renamed [Text (TMP)] to TextData.

    If you need any other information, please ask.
    Thank you.
     
  2. Strafe_m

    Strafe_m

    Joined:
    Oct 24, 2022
    Posts:
    72
    1. In your script, at the top ALWAYS add
    Using TMPro

    2. You can reference a text,
    public TMP_Text myText;

    3. Change it by
    myText.text = "Hello"

    3 easy simple texts!
     
  3. unitsume

    unitsume

    Joined:
    Oct 7, 2022
    Posts:
    31
    Thank you for your prompt reply.
    It was so easy.
    it worked fine.
    Thank you very much!
     
    Strafe_m likes this.
  4. HotYearKit

    HotYearKit

    Joined:
    Dec 4, 2018
    Posts:
    9
    SetText(content)
     
  5. unitsume

    unitsume

    Joined:
    Oct 7, 2022
    Posts:
    31
    Thank you, even A works.