Disabling Sprite Masking Effect in Scene View in URP Project For Development Purposes

Hello,

The issue:
I cannot find a non-hacky way to disable the effect of a sprite mask in the scene editor.
I have a sprite mask that covers a relatively large amount of space, masking numerous objects.
There are very many objects inside of the mask that are set to be only visible inside the mask. It works just fine in the game view… Technically it works in the scene view. It just needs a fixed for development. Here’s why:

The issue is that editing these objects inside the scene view is a tremendous pain, thanks to the fact that they are only visible if I am looking in the scene through the viewport of the mask… That’s extremely limiting when dealing with complex scenes with lots of objects and layers. Yes, in some situations, it may be a useful feature for a mask to be “in effect” in the scene view… It could help with visualization… But for my situations, with it being a medium-sized mask that covers very many objects that need to be adjusted just-so, it’s very annoying to have to edit in the scene view, but look in the game view, or adjust the camera in the scene view so that it is mushed right into the mask so I can see through it… Which is of course, limiting also.

I can’t just delete or mark the sprite mask component as invisible, because it will make all of those objects that are affected by the mask as invisible too. I can’t just unmark the objects as being affected by the sprite mask because there are too many. What I want to do is to be able to tell the scene view: “Hey, please just pretend masks don’t exist for a sec, so I can see what I am doing here”. I once saw a YouTube video of a tutorial that seemed to show this functionality in the past, but I suppose it is not available anymore, or else I cannot find it.

The workaround:
Fortunately, there is a workaround. It’s not perfect by any means, but I can get it to behave better by making an additional giant mask that covers a massive span in the editor, just for development purposes… Covering all mask layers. If I mark that mask as not-selectable, it lets me still be able to use the editor.

2 Likes

I was able to come up with a different and better solution for orthographic cameras. This may be a non-issue for me after all.

Applying masks to one cover-up item on a “only show when outside of mask” basis, seems to generally be a better idea than masking lots of items on a “show when inside” basis. Makes sense.

I can still see this feature potentially being useful to someone, if they wanted to make a Mixed Reality sort of situation… Where you can only see certain things if you look through a certain point in space… In that situation, you would not be able to just wall-off the outside area to prevent vision… You’d just specifically want to see components in the world through just that one sprite mask…

Because of that, I’ll keep the thread here I guess. I’ll also let you know if anything unexpected happens.

1 Like

Hello,
I got a workaround/solution:
Change your sprite’s Mask Interaction to NONE for development purposes. Add a script (“SetupMask”) to it which changes the Mask Interaction to your desired option in Start/Update/Custom function.

Just going on Max’s reply I’ve simplified his solution even further.
Just have your mask component disabled on the object you want and add the following script which will enable it during runtime:

using UnityEngine.UI;

[RequireComponent(typeof(Mask))]
public class MaskSetup : MonoBehaviour
{
    void Start()
    {
        GetComponent<Mask>().enabled = true;
    }

Hello everyone, I was looking for a non-hacky way to disable this effect aswell, and I believe this is the one.

Make sure you have checked the Sprite Mask option under the Draw Mode menu and thats it.

9666653--1376792--upload_2024-2-27_0-36-43.png

1 Like