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

TextMeshPro text still visible when using nested RectMask2D.

Discussion in 'UGUI & TextMesh Pro' started by Xerioz, Jun 26, 2018.

  1. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    upload_2018-6-26_21-16-12.png

    Reported this bug two weeks ago, but I can't find my bug report anywhere, nor did I ever receive any email confirmation to track its info ( which I assume what usually happens? ).

    So I thought maybe the bug reporting system is bugged, maybe it just disappeared into the void.

    When you nest two RectMask2D's. Lets say one mask and just a TMP input field ( which also uses RectMask2D ), that text will only be clipped around the borders of the parent RectMask. Once outside, the text becomes completely visible and parent RectMask2D no longer hides it.
    This happens with any package version along with the latest 1.3-preview package.

    This causes issue when trying to use TMP input fields in a simple scrollrect with a mask.
     

    Attached Files:

    Last edited: Jun 26, 2018
  2. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    338
    I have no idea why, but i am very curious to know, but mask2D doesn't mask properly, had several issues like that before.
    I always use the normal Mask component instead and I have never had a problem like that.
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I am traveling right now but will be back over the weekend and should be able to take a look at this early next week.
     
  4. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    Any news on this?

    This is a pretty major issue, considering that having an TMP InputField in a RectMask2D is an extremely common case.
     
  5. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    Is there any way we could track the progress of this bug? My bug reports don't seem to go through so I'm stuck with this thread as my only option.

    It's been 3 weeks with no response. Can we at least get an answer or an estimate?
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Until I figure out some better way to handle this, you can make the following change in the TextMeshProUGUI.cs file at around line 356.

    Code (csharp):
    1.  
    2. public override void Cull(Rect clipRect, bool validRect)
    3. {
    4.      // Comment this line below.  
    5.      //if (m_ignoreRectMaskCulling) return;
    6.  
    7.      base.Cull(clipRect, validRect);
    8. }
    9.  
    10.  
    The effect of commenting this line will result in incorrect behavior when using a scrollbar with a TMP InputField when the text scrolls outside the viewable area where you would still expect it to be visible but will get mask. Ie. this is the reverse of the behavior.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Here is a better solution which still not perfect is better than the previous change above which you should now ignore.

    Make the following changes in the TMP_InputField.cs at around line 789.

    Code (csharp):
    1.  
    2. if (m_TextComponent != null)
    3. {
    4.     m_TextComponent.RegisterDirtyVerticesCallback(MarkGeometryAsDirty);
    5.     m_TextComponent.RegisterDirtyVerticesCallback(UpdateLabel);
    6.     //m_TextComponent.ignoreRectMaskCulling = true; // Comment the following line.
    7.  
    8.     m_DefaultTransformPosition = m_TextComponent.rectTransform.localPosition;
    9.  
    10.     // Cache reference to Vertical Scrollbar RectTransform and add listener.
    11.     if (m_VerticalScrollbar != null)
    12.     {
    13.         m_TextComponent.ignoreRectMaskCulling = true; // Add the following new line.
    14.         m_VerticalScrollbar.onValueChanged.AddListener(OnScrollbarValueChange);
    15.     }
    16.  
    17.     UpdateLabel();
    18. }
    19.  
    This change will ensure that culling is only disabled when a Vertical Scrollbar is used on a TMP_InputField which are much less likely to be used inside of a ScrollRect.

    Please note that since all previous TMP_InputField objects have this IgnoreRectMaskCulling set to true, you need to manually disable this on existing child text objects of TMP Input Fields as they would continue to behave as per your report. You can set the Inspector to Debug mode to change this property on those child text objects.

    Given this change a try and let me know if this behaves correctly for your needs.
     
    Last edited: Jul 15, 2018
    Xerioz likes this.
  8. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    254
    Yes, that seems to fix my issue. Will you be doing a proper fix any time soon?
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The fix from above will be included in the next release of the TMP UPM package.
     
    SketchWork likes this.
  10. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    254
    Thanks buddy :)