Search Unity

UI Mask + Sprite Mask

Discussion in '2D' started by Primoz56, Dec 18, 2018.

  1. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    Hi all,

    I'm using both UI Image and Sprite Renderer to draw to the screen. I need both to be masked within the confines of the "box" that is my play area.

    If I add a Mask component, the UI Images get masked correctly, and if I add a Sprite Mask the Sprite Renderer images get masked correctly, but if I use both, the Sprite Renderer images do not render at all (the UI Mask component is affecting them).

    Can anyone let me know how I can mask both UI Image and Sprite Renderer images correctly?

    Thanks,
    Primoz
     
  2. knobblez

    knobblez

    Joined:
    Nov 26, 2017
    Posts:
    223
    Perhaps this will help you:

    https://docs.unity3d.com/Manual/LayerBasedCollision.html

    I'm not sure if transparentFX has anything to do with masks but there is a UI layer in there and it sounds like perhaps your masks are colliding with eachother.

    I don't know much about masks so take this advice with a lot of salt, lol.
     
  3. daleth90

    daleth90

    Joined:
    Dec 15, 2014
    Posts:
    10
    For anyone who reach this post,

    At Unity 2019, on Sprite Mask component, there is a toggle named "Custom Range". If you toggle on, you can adjust the affected layer. This means you can prevent the layer of UI Canvas be affected by Sprite Mask.

    Otherwise, if you toggle off, it affects all layers.