Search Unity

UI Layout under a ScrollRect is broken

Discussion in '5.2 Beta' started by CorruptScanline, Aug 8, 2015.

  1. CorruptScanline

    CorruptScanline

    Joined:
    Mar 26, 2009
    Posts:
    217
    There seems to be a bug in 5.2.0b5 that causes Layout components nested under a GameObject with a ScrollRect to be broken and not perform their layout logic.

    Here's how to reproduce the bug:
    1. Create a canvas
    2. Create a GameObject with a ScrollRect component.
    3. Create a child GameObject under the GameObject with the ScrollRect and attach a GridLayoutGroup component to it.
    4. Add a Text GameObject (A GameObject with a Text component) as a child under the GridLayoutGroup.
    5. Select this Text GameObject.
    6. Press Ctrl+D to duplicate the GameObject many times.
    7. Observe how the Text objects stack on top of each other instead of their layout position being updated.
    If you disable the ScrollRect component now and go select a Text GameObject and duplicate some more you will see that the GridLayoutGroup works correctly and all the Text GameObjects get their positions updated.
     
    Last edited: Aug 8, 2015
  2. CorruptScanline

    CorruptScanline

    Joined:
    Mar 26, 2009
    Posts:
    217
    If anyone else has this problem I found a work around. Attaching a Graphic component (such as an Image component) to the GameObject with the ScrollRect seems to fix the issue.
     
    lermy3d likes this.
  3. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    421
    Can confirm, I get the same bug with my layouts under ScrollRects.
     
  4. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    421
    So, this is still a problem in RC1. But, if you modify your ScrollRect to have a hierarchy like...
    ScrollRect -> Viewport (Clipping) -> Content
    it works again. Very frustrating that this isn't backwards compatible though.
     
    lermy3d likes this.
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,206
    We will take a look. Wont be for 5.2 as there is a work around but hopefully we can get it in a patch.
     
  6. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,852
    We haven't observed this problem ourselves, and would appreciate a repro project. Anyone have a bug case number?

    In the mean time, having an intermediary Viewport GameObject (as described nu Simie) should work around the problem.
     
  7. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    @runevision
    steps from post#1 easily reproduce it.
     
  8. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,852
    Often times when people say so it turns out to be true, but not always (sometimes there are extra circumstances that have to be met), so we really do want a repro project and the diagnostics info that is included with issues reported through the bug reporter. Then QA will try to reproduce the issue, and if they can, send it on to a developer to be fixed.

    So if you want a bug fixed, report the bug through the bug tracker. We use our bug tracker for tracking bugs, not the forums.
     
    lermy3d likes this.
  9. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    @runevision
    I went ahead and made a bug report from OP.
    (Case 721345) UI: Layout under a ScrollRect is broken (not confirmed by QA yet)

    Edit: confirmed
     
    Last edited: Aug 20, 2015
    runevision and Simie like this.
  10. BIMG

    BIMG

    Joined:
    Oct 1, 2014
    Posts:
    14
    The same problem.

    Case 722086
     
  11. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,852
    Thanks for the bug reports! We're looking into it.
     
    lermy3d likes this.
  12. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,852
    With your help, we have reproduced, identified and fixed the issue. Unfortunately it will be too late for Unity 5.2.0, but the fix should make it quickly into one of the 5.2 patch releases.

    If you need a solution more urgent, we recommend to use a setup where the content is not a direct child of the ScrollRect but has an intermediary View object in between:

    ScrollRect -> Viewport (Clipping) -> Content

    This is also what is used when using the GameObject > UI > Scroll View menu item.
     
    CrabSchell and Simie like this.
unityunity