Would it be possible to have a Sprite masked by two different Spritemasks? Specifically, to have an already masked Sprite also be masked by another SpriteMask? Here is a diagram explaining the issue I’m facing when testing:
The character portrait is supposed to be masked by SpriteMask 1 here, but they appear fully because of SpriteMask2.
I have the same issue with a similar setup.
I have read, that you can fix this via the sorting layers, but thats not true.,
This is probably the way to do it haven’t figure it out yet myself:
I think it is possible, but most definitely not something straightforward. I used SpriteMask with Mask Interaction property set to Visible Outside Mask. The trick is to invert sprite used for masking (now it is not rectangle but rectangular “hole” in plane) and define CustomRange property on SpriteMask component properly. Let me explain it on attached image.
Create inverted sprite for masking, i.e. plane with rectangular hole in it.
Create a single card.
For card “prefab” add SpriteMask component and set Mask Interaction property on SpriteRenderer component to Visible Outside Mask.
Place cards into grid. For each card set up proper Custom Range on SpriteMask component to avoid masking cards in neighbourhood, e.g. set first card sprite to layer 10 and SpriteMask for Custom Range 9-10, next card to layer 12 and SpriteMask for Custom Range 11-12 …
Finally, create SpriteMask for the group, just set the CustomRange property of this SpriteMask component to include all child cards layers.
Note: Orange outlines are sprite masks scaled to desired size.