ScrollRect, Masking and Multiple Child Objects

I have a quick question about using a mask with a ScrollRect.

I’m trying to create a simple map system using the new GUI. I thought I could make the map using lots of smaller tiles, each one a sprite.

Currently I have:

My canvas

– A ScrollRect with image and mask components

---- A ‘holder’ image

------- Lots of smaller images

I’m currently using an image component as that ‘holder’ image I tried putting another canvas there, as well as a panel, and nothing works as I expected. The ScrollRect needs to be directed to a UI element.

The mask and ScollRect work okay on the ‘holder’ image (I can move it and it is suitably masked) but none of the instantiated smaller tiles are masked, though each one is a UI image. They move with the ‘holder’ image but are visible at all times.

Is there something I’m missing? Is there some way to make a ScrollRect and mask work with lots of child objects?

This works properly as far as I am aware (see the scroll view example). Are you using a custom shader that does not support stenciling? (look at the default shaders to see how we do this). Raise a bug if this is not the case.

2 Likes

Thanks Tim. That wasn’t actually the problem but helped me identify what was wrong. I’d applied a transformation to my canvas which (strangely) wasn’t picked up by the children objects. I was therefore looking at the sprites from the wrong side, so they weren’t getting masked. Fixed that and everything now works.

1 Like

Ah yes, I believe we have this fixed (backface stenciling for UI) but it hasn’t made it’s way into our build yet.