Search Issue Tracker

Won't Fix

Votes

0

Found in

2021.1

2021.2

2021.2.0b3

2022.1

Issue ID

1354182

Regression

No

[Mobile] UIToolkit world bound values differ between identical buttons

UI Toolkit

-

Reproduction steps:
1. Download and open the attached "UIToolkit Bug.zip" project
2. In the menu bar, go to "Windows" > "UI Toolkit" > "Debugger"
3. In the "UI Toolkit Debugger" windows dropdown field, select "New Panel Settings"
4. Go to "VisualElement #crowns-container"
5. Select a few different "TemplateContainer #shop-crown-button" objects and observe their world bound values

Expected result: The world bound values do not differ between the objects
Actual result: The world bound values differ between the objects

Reproducible with: 2021.1.18f1, 2021.2.0b9, 2022.1.0a6
Could not test with: 2019.4, 2020.3 (Project breaks when downgrading)

  1. Resolution Note (2022.1.X):

    After multiple attempts at trying to find a way to do improve this situation, we ended up with keeping the status quo, as any change in behaviour introduced worse misalignment issues in other cases. In short, there is no easy way to align integer values to a non-integer scaling factor. Error accumulation needs to be taken into account and will eventually lead to the behaviour described.

    You can see the same kind of issues in browsers:
    https://jsfiddle.net/kb7a0p2L/1/

    When viewed at 125%, the 2 rows that are both defined at 10px become 12 pixels and 13 pixels

    Fortunately, there are ways that this can be worked around:
    In the panel settings, set the scaling at a "constant pixel size", then set PanelSetting.scale value manually by code. This scale should be set so that Panel.scale * GUIUtility.pixelsPerPoint is an integer number.

    Another way to prevent unnecessary texture filtering would be to use 9 slices background images. This way borders will be shown as-is and only the middle parts of the textures will be stretched to cover the area.

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.