Scroll Rect is not working with UI Mask

I created a gameobject with a scroll rect and image component. The scrolling part works fine. The problem is that when I add the mask component it doesn’t hide any of my UI prefabs. I’ve been trying to fix this problem for the last 3 days but I couldn’t find anything.

I think that you should add a Rect Mask 2D component instead of a Mask component to the ScrollRect.
Hope this answer helps you :slight_smile:

To answer my own question, I didn’t find any way to fix this but I have found a work around it. I cut my background intro 2 pieces and set the sorting layer to 19 to the inner square and 21 to the rest of the background. I just added a canvas in my prefabs and set it to override sorting to layer 20. Basically I had to simulate the effect of a mask by playing around with sorting layers. I don’t know if it is an Unity bug or I am forgetting about something but this fix seems to be working.

What helped for me is:

  • Check that on your overall mask element the component “Mask” is attached.
  • Check that on your elements below which should be under the mask and not be visible outside its borders on the UI component (Image / Text / …) the bool “Maskable” is enabled.

Hope it helps.