Using UI (canvas) Masks

HI! I was wondering if any of the Masks components will be “ported” to NeedleEngine. I’m working in a very simple effect where I want to mask all children of a specific object (all inside canvas) and I’m not sure where to start since apparently there’s no implementation in the Engine right now.


image.png

Original Post on Discord

by user 368204675922657280

Hey :wave: just to answer partially, the underlaying “UI engine” supports masking as seen on this gif, in css land it is called overflow:

https://github.com/felixmariotto/three-mesh-ui

So if you would be brave, you could fetch the elements in runtime and try setting the overflow on them.

Thanks for the reply, but I’m not sure if it will work for my use case. The idea behind of it was to animate some of the UI Elements via Timeline inside of Unity, plus I don’t quite understand how would I fetch a group of canvas elements while retaining the animations. The idea was to have a grid of textures, each of them would have a particular animation that I want to control from a TimeLine per each “container”.
I’ll attach a sketch that illustrates the thing:

by user 368204675922657280

Ahh the small squares are actually images/textures, while the container maaaaybe would be transparent.

by user 368204675922657280

I see, so, if you would use HTML you would miss the timéine editor, right?

If it’s images you may want to look at the stencil sample actually. The mask is the stencil and the images are „stenciled out“.

Technically this is the same that Unity does when you use scroll rects or masks in UI

yes, exactly

by user 368204675922657280

I’ll try it, but last time I opened it was on a project with the standard render pipeline and I couldn’t make it work. Is it specific for URP? or am i missing something?

by user 368204675922657280

I’ll try to set it up in a new project just for in case

by user 368204675922657280

Yes, URP is required if you want to use stencil without code

I figured it out!
Also just for curiosity: I checked that in the sample, you guys where combining ui (canvas) and regular meshes. Is it really hard to use the same logic, but for canvas elements by replacing the material for a custom unlit shadergraph?
I tried to do that but at first it doesn’t seem to work. :classyblobthink:

by user 368204675922657280