Search Unity

ScrollRect, Masking and Multiple Child Objects

Discussion in 'UGUI & TextMesh Pro' started by Valette, Aug 23, 2014.

  1. Valette

    Valette

    Joined:
    Jun 9, 2014
    Posts:
    68
    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?
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    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.
     
    JedBeryll and rakkarage like this.
  3. Valette

    Valette

    Joined:
    Jun 9, 2014
    Posts:
    68
    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.
     
    runevision likes this.
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Ah yes, I believe we have this fixed (backface stenciling for UI) but it hasn't made it's way into our build yet.