Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug TextMeshPro

Discussion in 'Scripting' started by TiggyFairy, May 13, 2022.

  1. TiggyFairy

    TiggyFairy

    Joined:
    Dec 22, 2019
    Posts:
    478
    For some reason, TextMeshPro destroys itself after loading? Any ideas how to fix this?


    Code (CSharp):
    1.  [SerializeField]private TextMeshProUGUI playerNameUI;
    2.  
    3. private void Start()
    4.         {
    5.             PlayerOneName = "Brian";
    6.             playerNameUI.text = PlayerOneName + "'s Turn!";
    7. }
    error.PNG
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,893
    presumably some other code that you haven't shared here is responsible.
     
  3. TiggyFairy

    TiggyFairy

    Joined:
    Dec 22, 2019
    Posts:
    478
    This is all the code referencing TextMeshPro. And the object itself is brand new.
     
  4. rickitz5

    rickitz5

    Joined:
    Aug 8, 2021
    Posts:
    31
    Have you tried this in a new project?
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,893
    Try it in a fresh scene. You have something else causing the issue. Also try re-assigning the reference and restarting Unity.
     
  6. TiggyFairy

    TiggyFairy

    Joined:
    Dec 22, 2019
    Posts:
    478
    Huh, it worked in the new scene! Any idea what might cause it to be 'destroyed' when nothing else references it? I still can't use it in my main project without it throwing that error, even after a restart.
     
    Last edited: May 13, 2022
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Destroy the text field and run your program.

    Or else DUPE it and destroy the first copy.

    Something will probably blow up.

    That something is what is turning it off.
     
  8. TiggyFairy

    TiggyFairy

    Joined:
    Dec 22, 2019
    Posts:
    478
    Sounds like a plan, thank you. I have a hunch it might be a dodgy plugin because it's the first bit of text I've added to the game, so nothing else I'm doing references it.