RectMask2D stops masking, when it's child has a child with Mask and Image components inside the RectMask2d area

It reproduces when UI Object with a "Rect Mask 2D" has a child object (which is not the first child in hierarchy) which also has a Child with Image(script) and Mask(script) components. Also, there must be another UI element on the Canvas, so that object with the "Rect Mask 2D" is not the most bottom child of Canvas.

To reproduce:
1. Open "Test" scene, from "SimplerUiProject.zip"
2. Open Game (or Scene) window and inspect, that RectMask2d is working correctly.
3. In Hierarchy find "Canvas -> RectMask -> Parent_of_Mask" and enable "Parent_of_Mask" object.

Expected result: Enabling this object does not change the way RectMask2d works.
Actual result: RectMask2d is no longer working.

Comments (7)

RectMask2D + TextMeshPro input field children which use RectMask2D, will bleed out the text outside the mask.

giawa

Jun 06, 2018 18:25

I can still reproduce this issue in Unity 2018.2.0b6 when doing a WebGL build. Shader.EnableKeyword("UNITY_UI_CLIP_RECT"); is a work-around we are currently using, but I don't think this is fixed yet (or there is another similar issue).

Dealing with a similar bug in 2017.2.0p2 (in our case the RectMask2D just randomly clips or doesn't clip various things). A workaround that *seems* to be working for us is to call this at startup somewhere: