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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Help with TextMeshPro (beginner)

Discussion in 'UGUI & TextMesh Pro' started by Jolteonthemaster, Nov 14, 2022.

  1. Jolteonthemaster

    Jolteonthemaster

    Joined:
    Aug 6, 2022
    Posts:
    3
    Hi guys,

    I'm currently working on a clicker game as my second ever game and I'm having some problems with TextMeshPro.

    I'm trying to use the GetComponent command but for some reason it's not working, the line looks like this:
    Code (CSharp):
    1. fakeText.GetComponent<textMeshPro>().text = "Hire Chef - $" + chefValue;
    I've already put using TMPro at the top of my script, but I still keep getting a null reference error. Can someone please let me know what I'm doing wrong? Let me know if you need the rest of the code or more information.

    Thanks.
     
  2. Jolteonthemaster

    Jolteonthemaster

    Joined:
    Aug 6, 2022
    Posts:
    3
    Nevermind, solved. Need to replace textMeshPro with TextMeshProUGUI
     
  3. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    743
    You can also use TMP_Text which is the base class for both