Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question TMP_Text field not showing new value even though it has a new value?

Discussion in 'UGUI & TextMesh Pro' started by Gordon_G, Jul 28, 2022.

  1. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    359
    I have put a TMP_Text object in a prefab, with a script that sets its value as a component on the same object.

    I get a reference to the text component in the scipt's OnEnable() :
    versionField = GetComponent<TextMeshProUGUI>();


    When I set versionFiled.text = "1.0 (12)" , the display never changes from the original text displayed in the inspector, even though the value changes - I can debug log to show that the new value is actually in the field:

    versionField.SetText( "1.0 (12)" );
    Debug.Log( "versionField.text = " + versionField.text );

    In the console I see: versionField.text = 1.0 (12)

    So clearly the field gets the text, but it never shows on the screen or in the field's inspector while the game is running. (which is just weird)

    What is going on?

    Note that I have tried directly referencing the TMP_Text field in a public variable in the script as well.
     
  2. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    359
    I'm officially dense - I had more then one copy of the prefab and mixed up the references