Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Cut out multiple holes into UI image

Discussion in 'UGUI & TextMesh Pro' started by abnerdev, May 5, 2021.

  1. abnerdev


    Mar 10, 2018
    I've been trying to find a way to mask out multiple rectangular holes through an UI panel for highlighting/tutorial.

    When it's just 1 element, I can easily edit the Stencil material and invert the mask properties and that's simple enough. The problem is that, with that mask setup, the cut out shape is the parent while the "background" is the child. But if I want multiple holes, guess what? I can't have multiple parents.

    I'm trying real hard to figure out how to make a cut out mask using the children as the cut out shapes. I've tried not using the hierarchy at all, but masks/stencil for UI simply won't work if they're not parent/children. I've tried the renderer features from the URP Forward Renderer but again, that doesn't give me anything different than just changing the Stencil properties and since those only work with parent/children, the problem persists. Tried using depth instead, but that didn't work, I guess because it's UI depth doesn't matter.

    Again, just making sure it's clear, it's UI Images. Sprite mask would do the trick if these were Sprite Renderers, but they're not, they're Images. And I want them to be Images, because I want the player to be able to click, press buttons etc where it's masked while having the click raycasts blocked where it's not.

    I appreciate any attempt to help!
    Example: I want the red rects to mask out those pixels on the big white panel