Search Unity

RectMask2D does not work when canvas render mode is Sceen Space - Camera or World Space, 2017.2.0f3

Discussion in '2D' started by poukoute, Oct 13, 2017.

  1. poukoute

    poukoute

    Joined:
    Jul 13, 2017
    Posts:
    1
    Today, I update my project to 2017.2.0f3 from 5.6.3p4. There is problem of that, the RectMask2D we put on ScrollRect does not work, when the Canvas render mode is Screen Space - Camera or World Space. Does anybody know why and how to fix that?
     
  2. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    I have the exact same problem! It seems a bug! Did you create a bug report?
     
  3. ganaware

    ganaware

    Joined:
    Jun 19, 2015
    Posts:
    6
    I have the same problem too!
    Are there any workaround?
     
  4. andrew-rc

    andrew-rc

    Joined:
    Jun 20, 2013
    Posts:
    10
    I have the same problem too. I'm on 2017.2.0f3 and all my RectMask2Ds have stopped working properly. Submitted a bug report just now.

    The RectMasks still work, sort of: after the whole object leaves the masked area it turns invisible, where it used to be per-pixel.
     
    Last edited: Nov 30, 2017
    ganaware likes this.
  5. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    This may have something to do with the new changes to include SpriteMask. I've swapped my RectMask2D components with regular Mask components along with an Image component without a sprite assigned, and that is working for me.
     
    Jaydeep000 and Samacvuk like this.
  6. andrew-rc

    andrew-rc

    Joined:
    Jun 20, 2013
    Posts:
    10
    Yeah, that's not possible for me, regular Masks are just way too slow.

    I have seen something really, really weird just now, in that if I toggled an image component on a totally unrelated gameObject (like not even the same root transform), my Rectmask2d would start working properly.

    I found that by just randomly disabling transforms in my scene until I saw the mask looking correct. Could speculate what's going on - but honestly, who knows. Could be anything! Help? :)
     
  7. ganaware

    ganaware

    Joined:
    Jun 19, 2015
    Posts:
    6
  8. fishbrainz

    fishbrainz

    Joined:
    Nov 27, 2013
    Posts:
    12
    Bump!

    This is still happening on 2017.3.0.f3, but only on WebGL builds.
     
  9. ufmsp

    ufmsp

    Joined:
    Oct 3, 2017
    Posts:
    11
    I still have this problem in WebGL builds (using Unity 2018.1.0f2).
     
  10. tsantoro92

    tsantoro92

    Joined:
    Aug 17, 2017
    Posts:
    2
    I also have this problem, but only in WebGL. (2017.3.1p1)
     
  11. brownce

    brownce

    Joined:
    Sep 14, 2015
    Posts:
    18
    Still having issues on 2018.2f2 with webgl builds. The mask has stopped working. Had to not upload a new webgl build to FB since not only did it not mask, when trying to use a scroll view that was suppose to be masked, the webgl build would crash.

    Note, this was with using the rect mask or the normal mask.

    If anybody stumbles across this, a temp fix here https://issuetracker.unity3d.com/is...d-image-components-inside-the-rectmask2d-area about the Shader works for now until an official release.
     
    Last edited: Jul 16, 2018
  12. BennyTan

    BennyTan

    Joined:
    Jan 23, 2014
    Posts:
    141
    This is still happening in webgl in 2018.2.14...
    How is this not fixed yet after a year....

    For those looking for a workaround, this works for me:
    Shader.EnableKeyword("UNITY_UI_CLIP_RECT");
     
    Last edited: Nov 26, 2018
  13. btyson_z

    btyson_z

    Joined:
    Aug 10, 2018
    Posts:
    9
    Can you explain this for an artist's sake? I'm prototyping with webgl and my masks don't work.
     
  14. AvalonXT

    AvalonXT

    Joined:
    Jun 22, 2015
    Posts:
    4
    Just insert this code somewhere at the start of the project. This will fix masks. This is C# line of code.
     
  15. tcvpromo

    tcvpromo

    Joined:
    Jun 7, 2017
    Posts:
    25
    in 2019.1 we have regression of this bug and workadound with Shader.EnableKeyword("UNITY_UI_CLIP_RECT"); stopped working. In there any new workadound?
     
  16. btyson_z

    btyson_z

    Joined:
    Aug 10, 2018
    Posts:
    9
    Thank you
     
  17. gresolio

    gresolio

    Joined:
    Jan 5, 2014
    Posts:
    17
    Code (CSharp):
    1. #if UNITY_WEBGL
    2. using UnityEngine;
    3. using UnityEngine.UI;
    4.  
    5. public class FixRectMask2dWebGL : MonoBehaviour
    6. {
    7.     private void Awake()
    8.     {
    9.         var items = GetComponentsInChildren<MaskableGraphic>(true);
    10.         for (int i = 0; i < items.Length; i++)
    11.         {
    12.             Material m = items[i].materialForRendering;
    13.             if (m != null)
    14.                 m.EnableKeyword("UNITY_UI_CLIP_RECT");
    15.         }
    16.     }
    17. }
    18. #endif
     
    chokochai and An-Item like this.
  18. lovexbma

    lovexbma

    Joined:
    Jul 1, 2016
    Posts:
    3
    after compared the source code of UGUI,found there some changed in the class RectMask2d with 2017.4.16f1。Debug the source code of UGUI,maybe find the Canvas that RectMask2d use for calculate is wrong。

    Suggest:
    1.Debug the source code of UGUI.Check the function PerformClipping of the class RectMask2d.
    Code (CSharp):
    1. Rect clipRect = Clipping.FindCullAndClipWorldRect(m_Clippers, out validRect);

    Check the value of clipRect.Check the value of m_Clippers.
    Maybe the Canvas is other.
    2.One solution.After the scene is loaded and before the content is show,disable all the RectMask2d scripts,when the content is ready,enable all the RectMask2d scripts.
     
    Last edited: Mar 12, 2020