Search Issue Tracker

By Design

Votes

0

Found in

2021.3.42f1

2022.3.42f1

6000.0.15f1

Issue ID

UUM-78205

Regression

No

Element is not perfectly centered when using percentage units in Position setting

--

-

Reproduction steps:
1. Open the attached “BugRepro” project
2. Enter Play Mode
3. In the Game view, set the scale to 5x
4. Observe the circle

Expected result: The circle outline is perfectly round
Actual result: The circle outline is uneven

Reproducible with: 2021.3.42f1, 2022.3.42f1, 6000.0.15f1

Reproducible on: Windows 11
Not reproducible on: No other environments tested

Note: Setting the Scale in the Panel Settings to 1.0001 fixes the issue

  1. Resolution Note:

    Thanks for the clean reproduction project.

    This is by design as any way on handling rounding will cause problem. The current algorithm guarantee that the total of the element will be filled if the percentages add up to 100% and has no corner case handling as they usually introduce more quirk than benefit.

    Here are two avenue to mitigate this :
    - Manually drive the scaling to be whole numbers of 1 at constant pixel size. This usually help a lot with having a predictable result
    - You could try setting the width (and left) explicitly instead of setting top and left. Maybe specify the widths in scaled pixels instead of % would also help a lot.

    Finally in unity 6 we exposed some utilities to help the users with the rounding, (see AlignmentUtils.FloorPanelPixelSize). You could possibly make some adjustments to the size of the element in the geometry changed event manually, but that would be a real last resort.

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.