Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity UI Shader that hides what is behind it.

Discussion in 'Unity UI & TextMesh Pro' started by _Daniel_, Jul 16, 2017.

  1. _Daniel_

    _Daniel_

    Joined:
    Feb 28, 2007
    Posts:
    2,608
    Does anyone have a UI shader that essentially cuts a hole in the UI? I tried the DepthMask shader from the wiki with no luck. Everything behind the image would be invisible revealing the camera that is behind.
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,602
    You can achieve that through various means, wither using a RestMask2D with the appropriate image.
    Or alternatively use the Soft Alpha Mask UI component in the Unity UI Extensions project (link in signature) which can use alpha masking to mask an image.

    hope that helps.
     
  3. _Daniel_

    _Daniel_

    Joined:
    Feb 28, 2007
    Posts:
    2,608
    I don't believe a Mask can achieve this effect. To clarify, I am having my Camera's viewport rect conform to a RectTransform as if it were an image itself. This is why I would like my camera to essentially block the UI controls that are behind it.
     
  4. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,130