Search Unity

TextMesh Pro InvalidOperationException while animating

Discussion in 'UGUI & TextMesh Pro' started by Lordscales91, Aug 10, 2019.

  1. Lordscales91

    Lordscales91

    Joined:
    Sep 30, 2018
    Posts:
    12
    Hi there. I have been trying to animate a TMP 3D object (Not the UI one). While animating I noticed some weird things.

    First, when I press record and start moving it, Unity's console fill with error traces like this one:

     InvalidOperationException: Stack is empty


    Edit:
    Here a Screenshot of the stack trace



    My guess is that it happens because Unity is inspecting the object for property changes, and it may be accessing an empty list where it expects to have some items.

    The second thing I noticed is that despite being technically a 3D object (I created it from Create > 3D object > TextMesh Pro - Text). It uses a Rect Transform, which is normally used only for UI elements as far as I know. The most weird part though, is that it stores the X and Y coordinates on the Rect Transform, but the Z coordinate is on a special "Position (Z)" property. I think this way of storing the coordinates is "confusing" Unity, and that's why some times it doesn't save correctly the Z coordinate.

    The Unity Editor version that I'm using is 2019.1.11f1 and TMP 2.0.1

    What I'm more concerned about is those errors I mentioned. Despite those, the animation plays just fine. Can I safely ignore those?

    Any idea about why it uses a Rect Transform?
     
    Last edited: Aug 10, 2019
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you change the Shader on the text object by the Mobile Distance Field to see if you get the same behavior?

    In regards to the question about the RectTransform, the primary reason is the need to define the area where the text lives for layout purposes. In the past, TextMesh Pro has its own TextContainer which served that purpose and was actually more efficient but the secondary reason, was due to the fact the base class TMP_Text inherits from MaskableGraphic which in turn requires / adds a RectTransform. As such, it didn't make sense to keep a TextContainer plus a RectTransform which basically serve the same function.

    P.S. I do plan on re-working this at some point to introduce the ability to have text containers that are not just rectangles.
     
  3. Lordscales91

    Lordscales91

    Joined:
    Sep 30, 2018
    Posts:
    12
    Thanks a lot @Stephan_B for your fast reply. That was it, it happens with the TextMeshPro/Distance Field shader but not with the TextMeshPro/Mobile/Distance Field. I switched to the non-mobile version because it had more options and I'm not targeting mobile, but I think I can just use the mobile version. But, what is the reason for those errors to pop out? It only happens in edit time, in play time it works just fine.

    About animating the object, I've ended up using a workaround, I created a parent empty and animate it instead of the TMP object directly, that way Unity registers correctly the position of the empty, and the TMP child follows it just fine. So that settles it.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I was just made aware of this issue a few days ago. The issue either comes from the Animation Editor or the TMP Material Editor. I should be able to take a closer look over the next few days.

    Since this is an Editor issue, this is why it has no effect in Play mode.
     
  5. Sinister-Design

    Sinister-Design

    Joined:
    Sep 19, 2015
    Posts:
    66
    I've just run into this same issue myself. It's quite frustrating. :S