The question is answered, right answer was accepted
[UI] Is it possible to have certain elements ignore the parent mask?
Is there a way to have certain children of a mask ignore it? I'm using a scrollview which contains buttons so I want them to be cut off by the mask. However, clicking these buttons opens a pop up to the right of the scrollview which obviously are being blocked by the mask too.
Is it possible to have these elements ignore the mask?
Yes it is. UI $$anonymous$$ask is using stencil buffer. https://docs.unity3d.com/$$anonymous$$anual/SL-Stencil.html
What happen here is that UI mask will only show stuff that have stencil buffer = 1 or 255. As all unity UI default sprite have buffer =1 or 255. That is why stuff inside UI mask got show.
So in theory, if I change the stencil buffer of the parent image to anything but 1 or 255 it will be displayed outside of the mask?
Is there any way to access the stencil buffer of the default UI material attached in the inspector? Or do I need to edit the shader?
Last time I check, Unity do not allow you to change default Shader. So you have to download it from archive and change it.
So technically, If you set default UI shader or sprite shader stecil ID buffer to any number except 0. $$anonymous$$ask will consider it as invisible.
$$anonymous$$ask will only show stuff that have stencil ID = 0. Any other stuff behind the mask will be invisible.
I am not sure that is what you want. So look it this as result: https://github.com/EsotericSoftware/spine-runtimes/issues/941
Answer by ConorArup · Aug 08, 2018 at 09:27 AM
I managed to get it working!
Added Stencil pass to a font shader I found and now the colours are all being correctly displayed while outside of a mask!
Adding this to the shader was most important:
Stencil {
Ref 1
Comp Greater // Greater displays it outside of mask
Pass Keep
}
Hi, I'm not really experienced with shader coding so please help me if you can. I tried using the same method you mentioned for an image and it worked but now the image is only displayed outside of the mask (The image has a portion inside of the mask area and a portion inside of mask area) Is there a way for the image to be drawn on tp and completely ignore the mask? I hope you understood my qustion Thanks
Follow this Question
Related Questions
How can i use UI Mask to get a soft fade? 0 Answers
NGUI 2.7 clipping with the new UI? 0 Answers
UI Mask not working 1 Answer
UI Mask dont aliasing children images 0 Answers
Too Many Batch and SetPass Call counts while using ScrollViews 1 Answer