Update: [ Bug ] TextMesh Pro and Rect Mask 2D component not working

I have a ScrollRect component with the Rect Mask 2d component which together creates a mask around the corners. I was using the basic UI Text component and as default it has the Maskable option and is enabled by default.

8000517--1028667--upload_2022-3-28_15-24-14.png

This was I could get the text component to respect the mask from the Rect Mask 2D and the result is fine like this:

8000517--1028664--upload_2022-3-28_15-22-19.png

Recently I decide to move all my texts to TextMesh Pro and today I realized that it is not masking the text. I couldn’t find any option that worked so I could have the same behaviour as default UI Text
8000517--1028661--upload_2022-3-28_15-18-31.png

I found a mask option under a mobile shader, but I don’t think this is the way to achieve the effect I am hoping for.

Am I missing something? Any help on this would be great.

UPDATE:

I did a test with a gameobject with Rect Mask 2D and 2 gameobjects inside it… a default UI Text and a TextMesh Pro UI (Text). I used the standard font assent from textmesh pro and it does not receive the mask from the Rect Mask 2D.

UPDATE AGAIN:
Unity version: 2020.3.8f1
TextMesh Pro version: 3.0.6

It is a bug: Unity Issue Tracker - RectMask2D Softness property has no effect when used on TextMeshPro Text

1 Like

Inside the “TextMeshPro - Text (UI)” compoment there is a “Maskable” property under the “Extra Settings”

Thanks. I was looking elsewhere but missed that section.

I see the option is checked, even though it still did not get the mask. Is this maybe a limitation? Or again am I missing (another) thing?

Thanks again for any help.

UPDATE
Topic updated, it is a bug

The case that you referenced above was related to the softness control of the RectMask 2D. That specific issue was resolved in version 3.2.0-pre.2 of the TMP package. The latest preview release is version 3.2.0-pre.3.

In order for the masking to work with the RectMask 2D, you don’t have to switch shaders. You should be using either the mobile SDF shader or the full distance field shader. No need to switch to the masking shader which provides for the ability to use a masking shape / texture which can be animated. See example 19 - Masking Texture & Soft Mask included in the TMP Examples & Extras.

I would suggest updating to version 3.2.0-pre.3 and let me know if the issue still occurs. If it does, please provide me with a simply scene to look at for testing. I just tested on my end and everything appears to work as expected so something about your setup is likely causing the behavior you are seeing. I just need to reproduce that setup.

Thank you for the clarification and the support. I’ve been back in forth with TextMesh Pro and as I’m about to release the game on production and as it’s not recommended to use an alpha release for this cenario, I will skip this asset for this project for now.

Thanks again for the support.

What is in preview are the new features being introduced but the core functionality is deemed stable. These previews also include the bug fixes reported in preview releases which includes the verified releases.

I personally consider 3.2.0-pre 3 more stable than version 3.0.6 with respect to the core functionality. New features like Dynamic OS font assets are what is in preview for instance.

Hello, so on that project I dodge TextMesh Pro, but in a new project I have decided to use it on a new Unity version, 2021.2.0f1 to deal with the same problem from this thread, the transparency related to Rect 2D not been acting properly. After trying to see the pre-packages without luck I found a post from you @Stephan_B ( TextMesh Pro Open Source Repository? ) and I have edited the line on manifest, so now I have “com.unity.textmeshpro”: “3.2.0-pre.3”, but as soon it finishes the import all my texts changed to this

8092322--1047113--upload_2022-5-1_2-10-15.png

I tried to recreate the font asset and still the same. Any clues? Thanks.

2 Likes

I was in the same situation as you at first, and then I imported the missing basic resources through Window→TextMeshPro→Import TMP Essential Resources and it was normal.

I am having the same problem, masking is ON on my text component but soft masking is not affecting the text, only the images

I am using TMP 3.0.6 and Unity 2021.3.25f1 on MacOS

3 Likes

Bump

It’s been a month :slight_smile:

Bump

Same problem. Unity 2023.1.7 and TMPro 3.0.6

I seem to get it to work just fine by following the instructions above.

  1. Open the manifest file in the Packages folder, search for “com.unity.textmeshpro” and switch version to “3.2.0-pre.3”.
  2. After downloading the new version, finish it by going to Window->TextMeshPro->Import TMP Essential Resources.
  3. The mask should work correctly now.

I am using Unity 2022.3.10f1.

Looks like this works to install it:
9523747--1343596--upload_2023-12-11_19-45-27.png

9523750--1343602--upload_2023-12-11_19-47-27.png

2 Likes

Anyone know if TMP preview releases are dependable, in practice?

Looks like 3.0.6 is latest release, then it jumps to 4.0-pre without another.

9523750--1343602--upload_2023-12-11_19-47-27.png

3 Likes

Two reports with this issue.

And and old solution. I’m checked it right now Unity changed the shader

Temp solution fix shader TMP_SDF.shader add soft mask into it

  1. Add two params from soft mask on line 161
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;

Replace line 227 with the next code.

output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + pixelSize.xy));

Add soft mask in calculations