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

I can't change my text

Discussion in 'UGUI & TextMesh Pro' started by AnonymousUser1000, Dec 1, 2022.

  1. AnonymousUser1000

    AnonymousUser1000

    Joined:
    Dec 1, 2022
    Posts:
    2
    I tried 2 hours to change my text just to see that unity basically thinks TextMeshPro doesn't exist

    here is the script
    Text ScoreText = GameObject.Find("Canvas/ScoreText").GetComponent<Text>(); - This detects
    ScoreText.text = "Test"; - [Always an error in console log , shows no error when save it]
    i tested transform component and worked
    but for some reason text component doesn't work and always i get a Null when i do Debug.Log("")

    The error is always Object reference not set an instant of an object
    There is a fix ? Because i looked at like over 20 forums and i get same error no matter what i do.
     

    Attached Files:

  2. AnonymousUser1000

    AnonymousUser1000

    Joined:
    Dec 1, 2022
    Posts:
    2
    I finally found a fix in the end the solution was Using TMPro , i am new using unity btw.
     
    Last edited: Dec 1, 2022
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    37,130
    That should be two seconds, not two hours. Why? Because its ALWAYS the same three steps.

    How to fix a NullReferenceException error

    https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

    Three steps to success:
    - Identify what is null <-- any other action taken before this step is WASTED TIME
    - Identify why it is null
    - Fix that
     
    Last edited: Dec 2, 2022
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,738
    So you know, the 2D forums are not related to UI so I would ask that you please not post about UI stuff on this forum.

    The UI forums are here so I'll move your post for you.

    Thanks.