Search Issue Tracker

Fixed in trunk

Votes

0

Found in [Package]

1.0.0-preview.14

Issue ID

1330415

Regression

No

Scrollview incorrectly scales elements above and below when resizing the custom window

Package: UI Toolkit

-

How to reproduce:
1. Open attached project "Bug Test.zip"
2. Open custom window (Tools/Test Window)
3. Resize the window

Expected result: Buttons at the bottom are not resized and don't disappear
Actual result: Buttons at the bottom stay fixed in size

Reproducible with - 1.0.0 (2019.4.25f1), 1.0.0-preview.14 (2020.3.5f1), 1.0.0-preview.14 (2021.1.5f1), 1.0.0-preview.14 (2021.2.0a15)
Not reproducible with - 2018.4 (no package)

  1. Resolution Note (fix version trunk):

    This behavior is due to the way Flex distribute space among sibling elements. This can be configured using the flex-grow and flex-shrink parameters.
    Flex-grow gives a weight to an element and when additional space is available, it will be distributed according to the relative flex-grow values of the elements. Flex-shrink is the same, but influences how flex removes spaces when not enough is available. Setting flex-shrink to 0 will ensure that elements won't get any space removed when not enough is available.

    Here is the same uxml, with the flex-shrink values set:

    <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
    <uie:Toolbar style="flex-shrink: 0;">
    <uie:ToolbarButton text="Button" />
    <uie:ToolbarButton text="Button" />
    <uie:ToolbarButton text="Button" />
    <uie:ToolbarMenu>
    <uie:ToolbarButton text="Button" />
    <uie:ToolbarButton text="Button" />
    </uie:ToolbarMenu>
    </uie:Toolbar>
    <ui:ScrollView>
    <ui:Label text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut et sapien neque. Duis a massa finibus tellus tristique auctor. Phasellus nisl nisi, faucibus sit amet quam ut, porta ultrices magna. Nullam interdum, leo at suscipit semper, sem nisl placerat ipsum, eu semper sapien sem nec ex. Vestibulum a facilisis ex. Etiam ut accumsan enim. Cras tincidunt tristique mauris et fermentum. Nam nisi sapien, lobortis sit amet eros eu, hendrerit pulvinar ex. Cras ac maximus metus. Phasellus eu euismod diam, ut mollis arcu. Sed sollicitudin sagittis lacus quis faucibus. Aliquam ac hendrerit elit.&#10;&#10;Curabitur venenatis sapien non ipsum ullamcorper lacinia. Cras dignissim suscipit ante, luctus mollis augue. Phasellus vel tempus lectus, et dignissim velit. Aenean quis nulla at risus dapibus congue. Morbi faucibus vel justo eleifend pretium. Nulla facilisi. Sed pharetra vitae magna aliquet bibendum. Suspendisse sit amet nulla non libero convallis rutrum. Maecenas vulputate nibh vitae sem luctus pellentesque.&#10;&#10;Nam id dui nec mi molestie egestas imperdiet non enim. Donec mattis in enim quis consectetur. Praesent lacus augue, ornare ut cursus egestas, tempor non mauris. Pellentesque vitae pulvinar tortor. Donec augue risus, rutrum vel nulla quis, iaculis efficitur mi. Etiam mi tortor, ultrices nec pellentesque a, pharetra sit amet nisl. Proin iaculis nisi ac enim varius, at sodales lectus faucibus. Aliquam laoreet diam sed elit egestas gravida. Donec ac ullamcorper neque. Maecenas sed justo feugiat, auctor lorem vel, euismod magna. Fusce venenatis convallis mauris sed sollicitudin. Morbi feugiat ipsum sit amet risus lacinia, quis vulputate mauris suscipit. Quisque dapibus laoreet euismod.&#10;&#10;Curabitur semper vel orci molestie convallis. In dictum scelerisque pharetra. Vestibulum dui purus, iaculis eu magna quis, laoreet vulputate nisi. Nullam lacus mi, auctor et turpis sit amet, faucibus dignissim urna. Sed sit amet odio sit amet leo hendrerit molestie at id sem. Phasellus vitae libero elementum ligula gravida hendrerit. Aliquam erat volutpat. Aenean et ex sed orci mattis malesuada.&#10;&#10;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce cursus velit eros, eu eleifend eros cursus blandit. Quisque sit amet convallis neque. Morbi eget viverra tellus. Cras ac tincidunt arcu, tempor aliquam erat. Donec fringilla ultricies mi vel consectetur. Aliquam vel congue leo. Mauris non nibh in odio porta venenatis. Ut tincidunt nibh quis lobortis varius. Curabitur mollis lorem tincidunt tristique malesuada.&#10;&#10;" style="white-space: normal;" />
    <ui:VisualElement>
    <ui:Button text="Do something positive" style="white-space: normal;" />
    </ui:VisualElement>
    </ui:ScrollView>
    <ui:VisualElement style="flex-shrink: 0;">
    <ui:Button text="Button" />
    </ui:VisualElement>
    </ui:UXML>

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.