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

3D TMP produces a MissingComponentException for CanvasRenderer

Discussion in 'UGUI & TextMesh Pro' started by TheHeftyCoder, Apr 15, 2021.

  1. TheHeftyCoder

    TheHeftyCoder

    Joined:
    Oct 29, 2016
    Posts:
    91
    This is just weird. I'm in a situation where I need to use both 3D-Tmp and UI-Tmp in a Canvas, to utilize the scrolling capabilities. It was all going well, until I upgraded to Unity 2020.2 and later to 2020.3. Now I'm getting a "MissingComponentException" for CanvasRenderer for every 3D-Tmp in the scroll. I realize that a CanvasRenderer isn't needed anymore for 3D-Tmp, but it's somehow throwing an exception there. This is all fixed if I manually drag all the objects outside of the ScrollView / Canvas and inside again.

    I think I can work around this by skipping a frame before adding the objects in, but I just wanted to drop this bug here in case it is not bound to my case which I upgraded my project to another version Screenshot_1.png
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What version of the TMP package are you using?

    In 2020.x a CanvasRenderer is no longer automatically added to text objects. As such, and if you are using an older version of the package, you might get that behaviors.

    Version 3.0.5 of the TMP package was just released today.
     
  3. TheHeftyCoder

    TheHeftyCoder

    Joined:
    Oct 29, 2016
    Posts:
    91
    Even UI-TMP doesn't need CanvasRenderer?

    I was using 3.0.4. Just downloaded 3.0.5, still the same behavior. I don't understand, if I manually unparent the gameobjects with 3D TMP and put them back in the ScrollView, the error doesn't show up anymore. I understand you've even removed the RequireComponent, but the error is randomly produced when the Graphics class is trying to Raycast.

    EDIT: The error doesn't show anything, but I've come to believe something is happening with Doozy UI which I'm currently using in the project. Can't really know for sure, I'll test more and I'll come back with a reply.
     
    Last edited: Apr 16, 2021
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The TextMeshProUGUI component does need a CanvasRenderer. The [RequireComponent(typeof(CanvasRenderer))] is in the TextMeshProUGUI.cs script.

    The change between 2019.4 and 2020.x is that the CanvasRenderer is no longer automatically added by the inherited Graphic class. Perhaps based on your setup, you need a CanvasRenderer even on those normal <TextMeshPro> objects. As such, I would suggest adding one manually or via code if you are instantiating those objects.
     
    TheHeftyCoder likes this.
  5. TheHeftyCoder

    TheHeftyCoder

    Joined:
    Oct 29, 2016
    Posts:
    91
    Indeed, this has worked! Thanks for your help!
     
    Stephan_B likes this.