- Home /
Poke hole in UI Image?
I'm trying to poke holes and stuff through a UI image so the player can see the background. I thought I could do this with a mask, but it seems I need to reverse how masks work.
My image is a scroll rect so the hole can move up and down, and the player should see the background through it.
Any help? I tried a shader I found in some threads, but they weren't working in Unity 2017.
bump! Please guys this is for a jam, I don't have much time :O
Answer by llentinantl · Nov 15, 2017 at 09:21 PM
As of Unity 2017.2.0f3, it is possible to select Mask Interaction property for sprite renderer, which allows you to select, if you want object to be seen only inside mask, or to be hidden under the mask. So, there are two possible ways for you to do this:
Assign renderers of all sprites, that need to have holes in as "Visible outside mask".
Put second background right above everything else, with sorting layer, which overlaps everything else, and set for it "Visible Inside Mask". This will make this double background be visible in mask, and its sorting layer will make it to appear over everything else.
Your answer
Follow this Question
Related Questions
UI Masking (Type visiblity of the content outside and inside of mask ) 0 Answers
Create UI Mask from Childrens images 2 Answers
UI mask with a 3D object 1 Answer
TextMeshPro InputField masking not working 0 Answers
Can I combine 2 or more UI masks? 0 Answers