Gui: Adapt...ToChildren using rounded values (adaptive scaling)

Hi,
in this playground with a StackPanel you can see that the Container has the wrong size, leading to the buttons being cut off by a small amount, when the widow size changed (upscaling). This seems to happen, because the buttons have values with many decimal places, e.g. 214.51612903225808px, but the container seems to cut off all decimal places, and uses 214px instead.

In the second playground example, you can see, that adaptHeightToChildren is set for the container and its’ height has all decimal places cutt off when it’s upscaled. The width on the other hand (because no adaptWidthToChildren is set) uses the exact values of both buttons added together (with decimal places).

I don’t know if the rounded values are the “correct” ones, or the exact ones, but it should be the same for all calculations.

Thanks

1 Like

Taking a look at the playgrounds, this seems to be caused by the adaptive scaling :thinking: I also noticed that, if I open the GUI editor from the Inspector, the cutoff disappears, probably because of some recalculation going on. I’ll ping @DarraghBurke so he is aware of this

If you open the GUI Editor from the inspector in the playground, the cutoff disappears because the values are set to the original non-scaled width/height, while the GUI Editor Window is open. If I close it, it resets to the upscaled ones, again showing the cutt off.

Hey, I am looking into this one now. We have not really decided on a consistent approach to rounding in the GUI system, so it’s going to take a little time to figure out what the right behavior is. Thank you for bringing this up! I will keep you posted on what we come up with.

1 Like

Hey @carolhmj @RaananW I want to keep this on your radar. This is something we talked about a bit during the GUI editor dev process but never fully investigated or came up with the right approach.89

1 Like

Thanks, I’ll keep it assigned to me! :smiley:

1 Like

Any news on this topic? It’s still an issue for me.

Apologies, we couldn’t find the time to discuss the rounding issues, but even without them, we should at least round up the results so there’s no risk of cutting them. I’m going to work on this ASAP.

Hello again! I investigated the issue and found that rounding up the calculation results solves it: Round up ideal width/height calculations so no control is cut off by carolhmj · Pull Request #13724 · BabylonJS/Babylon.js (github.com)

2 Likes

Thanks, just wanted to confirm that it’s also working correctly in my project now.

2 Likes