Search Unity

TextMesh Pro Bug: MissingReferenceException when using TMPro text in a scroll view

Discussion in 'UGUI & TextMesh Pro' started by Mloren, Jun 18, 2018.

  1. Mloren

    Mloren

    Joined:
    Aug 20, 2011
    Posts:
    83
    Hi,

    I'm trying to add a TMPro - text object to a scroll view so I can use the scrollbars but it's breaking the TMPro object. This is reproducible in 2017.4.3f1

    Steps:
    1. Create a Scroll View
    2. Add a TextMeshPro - Text object as a child of the Scroll View's Content object. So your hierarchy should be:
    • Canvas
      • Scroll View
        • Viewport
          • Content
            • TMPro text
    3. Edit the text in the TMPro object, I just selected the "New Text" that's in there by default and hit copy then paste about 10 times so there is more text than can fit in the box.
    4. Change the Overflow settings to "Scroll Rect"
    5. Change the Overflow settings back to "Overflow"

    Result:
    "MissingReferenceException: The object of type 'Material' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object."

    Once this happens, the TMPro object is permanently broken. Even if you unparent it from the scroll view it keeps displaying the error whenever you change the Overflow settings and the text is replaced with pink squares indicating no material. If you reset the Material Preset it temporarily fixes it but it breaks again as soon as you change the Overflow setting.

    The only solution I can find is to delete and recreate the object.
     
  2. Mloren

    Mloren

    Joined:
    Aug 20, 2011
    Posts:
    83
    Update: I found an easier way to reproduce this, it seems it has nothing to do with the Scroll View, and is simply the "Scroll Rect" overflow option.

    1. Create a TextMeshPro - Text object in the canvas:
    • Canvas
      • TMPro text
    2. Add text to the TMPro text object so it overflows
    3. Change the Overflow settings to "Scroll Rect"
    4. Change the Overflow settings back to "Overflow"

    Error occurs.