Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

TextMesh Pro How to render TextMeshPro the last regardless of Hierarchy?

Discussion in 'Unity UI & TextMesh Pro' started by 5argon, Sep 15, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    694
    You know uGUI relies a lot on hierarchy ordering. And each TextMeshPro text will probably have its own SDF material so it cannot be batched. The ideal for non-occluded TextMeshPro is to have them drawn the last after everything else.

    In this picture, the 873 and 1000000 number was from the same SDF TextMeshPro material (with the "Overlay" variant so they would draw the last) But when using Frame Debugger, it is still being drawn sequentially from top of hierarchy to the bottom, resulting in batch breaking even though nothing will be displayed over them.

    Screenshot 2018-09-15 17.01.45.png

    Here, the hierarchy tree would look like this because I wanted them to animate together. Everything are under the same Canvas :

    Code (CSharp):
    1.  
    2. >Judgement
    3. >>RedPerfect
    4. >>>873
    5. >>Perfect
    6. >>>873
    7. >>Good
    8. >>>873
    9. >>Miss
    10. >>>873
    11. >Score
    12. >>1000000
    13.  
    My current solution is to "peel" them out to a separated canvas (Inherit settings, but with overridded sorting to be the old one +1) positioned at the bottom, collecting them. This way they would be drawn last like before, but the batch not breaking. Because a new canvas will guarantee separated batch.

    Code (CSharp):
    1.  
    2. >Judgement
    3. >>RedPerfect
    4. >>Perfect
    5. >>Good
    6. >>Miss
    7. >>InnerCanvas
    8. >>>873
    9. >>>873
    10. >>>873
    11. >>>873
    12. >Score
    13. >>1000000
    14.  
    But it is a hassle because I have to do this after the animation and restore them when I want to do animation again so they go together with their parents.

    Can you make the "Distance Field Overlay" material drawn last regardless of where it is on the hierarchy? (Preferrably sorted by material types after they are all grouped the last) Or any better way? Thank you.