Sprite Clipping

Hi,

I was wondering if masking based on a background image is planned. I see that it say mask clipping on this page: Unity - Manual: Comparison of UI systems in Unity is partial, but I might have misunderstood what mask clipping is. I just assumed it was masking based on a sprite since above it is rectangular clipping.

I really miss this feature as I transition from UGUI to UIToolkit. Am I missing something or is it not/won’t be implemented?

Thanks!

1 Like

Hello,

The (partial) mask support refers to the overflow:hidden USS style, which clips the content outside the element’s region. If an element has rounded border (though the border-radius style), a mask is generated so that the content of the element doesn’t overflow.

As I understand it, what you are asking for is providing an alpha mask through a sprite, so that elements with the mask applied will be transparent where the sprite is transparent. Is that correct?

This is a common request. This kind of raster effect is unsupported right now in UI Toolkit, but planned for later, as well as other raster effects.

Can you give us more details about how you used sprites with UGUI? Maybe we can find a workaround.

Ah, right so I did misunderstand. This is exactly what I was looking for! Glad to hear its coming soon. :slight_smile:

One instance was having rounded corners in a scrollview and using a sprite to mask the corners, but you mentioned that it will generate a mask for that so that is a non-issue now!

The other issue I will have to just wait for the implementation. That issue is really just a work-around for another issue.

Thanks for the information!

1 Like

Yeah I really miss this feature as well… it’s very important for me to create any kind of HP bars, status bars, etc.

I’m not sure how I could use UI Toolkit without it, as much as I love UI Toolkit so far.

1 Like

@MousePods
On another discussion, it has been suggested to use a SVG asset as a background image, with overflow set to hidden.
In this case, the element can be used as a mask for its children elements :

1 Like

Thanks for the heads up!

What is the status of this feature request? In case the feature is already available in Unity 2021.2.4f1 then please give an explanation how to use it in UIToolkit.

1 Like