Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sprite Clipping

Discussion in 'UI Toolkit' started by MousePods, Jan 29, 2021.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    808
    Hi,

    I was wondering if masking based on a background image is planned. I see that it say mask clipping on this page: https://docs.unity3d.com/2020.1/Documentation/Manual/UI-system-compare.html 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!
     
    ModLunar likes this.
  2. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    998
    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.
     
  3. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    808
    Ah, right so I did misunderstand. This is exactly what I was looking for! Glad to hear its coming soon. :)

    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!
     
    mcoted3d likes this.
  4. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    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.
     
    MousePods likes this.
  5. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    242
    MousePods likes this.
  6. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    808
    Thanks for the heads up!
     
  7. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    313
    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.
     
    ModLunar likes this.