UI mask overlapping a Sprite mask

My main issue is that, I have a canvas, that contains an image which needs to be masked. This works fine by itself, but if this image is overlapping into a sprite mask, the sprite mask overrides the canvas mask, and makes parts visible that shouldn’t be visible.

First of all, how could a sprite mask interact with a canvas rendered image? I mean there is not even an option in a canvas rendered image called “Mask Interaction”.

Im having this same issue!

Hi, this is not a solution, but as far as I know, both masking systems work with the stencil buffer to write their mask information. That’s probably why they can be overwritten. Maybe that’s a helpful starting point for some further investigation.

Heya I found that for a similar issue I was encountering the issue was not using a Sorting Group component when I should have been. Once the Sorting Group was applied to the correct game object, the issue was resolved.

Before:
8819221--1200379--upload_2023-2-19_18-11-16.png

After:
8819221--1200385--upload_2023-2-19_18-17-11.png

The hierarchy:

  • Added Sorting Group to component ‘rug_fences_treats’
  • Offending Sprite Mask was on component ‘mask’
    8819221--1200388--upload_2023-2-19_18-19-9.png

The UI element in the screenshot was in a canvas in a separate part of the hierarchy, using a UnityEngine.UI.Mask component.