fix: Slider put in Canvas NaN Exception #2604
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Details
Handled
Slider
UIElement measurement whenavailableSizeWithoutMargins
is infinity. This was done by setting it to max value. The UI math after this cannot handle infinity values. Also other UI Elements provide real numbers for desired size.I have considered multiple values to put in as the default. But when the the UI Editor Slider Layout section is first opened the visual width is set to a high number, maybe max float. Due to canvas not having a limited size the Slider lacks the support to handle what to do in this situation. When the Layout is open the
availableSizeWithoutMargins.X
value becomes a high number, meaning that value is originally from the parent, this is is why I chosefloat.Max
.It also worth noting that there is still a bug behind the original bug. The first slider put into a canvas wont resize on width change until it is re-selected. I think most UI elements measure override to smallest desired size, while the slider appears to use the
availableSizeWithoutMargins
which is infinity for this issue configuration.I plan on leaving the issue like this. Unless someone has a better default, please test this solution before suggesting.
Related Issue
#2236
Types of changes
Checklist