Search Unity

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:
    797
    You can also use TMP_Text which is the base class for both