Hello there!
The Context
So I’ve been trying to make a Changelogs UI as seen in the picture shown below
Which Consists of:
Major is the one with an image, Minor is the one without. The Changes TextLabel uses AutomaticSize for Y axis
The UI takes its text from a module that contains a table of each version’s details, here is an example of one of the version’s contents for the Changes TextLabel text that uses multiline strings for the table:
The Problem
So I’ve been experiencing where the automatic sizing misses a couple of lines/paragraphs on the Changes TextLabel leading to an overlap with the next changelog as seen below:
This happens in all really tall texts, which mostly include Major changelogs.
Tried Solutions
1. GetTextSize
S.Changes.Text = L[i].Content
local ActualTextBound = TextService:GetTextSize(L[i].Content,16,"SourceSans", Vector2.new(S.Changes.AbsoluteSize.X, 1000000000000))
S.Changes.Size = UDim2.new(1,0,0,ActualTextBound.Y)
produces pretty much the same result as AutomaticSize.
2. Manually increment the Y Textlabel offset size for each newline.
S.Changes.Text = L[i].Content
local ActualTextBound = 0, Spacing = 20
for rep in str:gmatch("\n") do
ActualTextBound += Spacing
end
S.Changes.Size = UDim2.new(1,0,0,ActualTextBound.Y)
Can work at times with higher Spacing, but leads to shorter changelogs being much taller than the TextBound itself.
3. Make the Textbox really large and input the content to get the ‘actual TextBound’ and using that as the textlabel size.
-- the Changes TextLabel Y offset is already set by 10000000 by default.
S.Changes.Text = L[i].Content
local ActualTextBound = S.Changes.TextBounds.Y
S.Changes.Size = UDim2.new(1,0,0,ActualTextBound)
I got a bit desperate, so this was a bit hacky, didn’t work either way as it still overlaps. Deeper look I think it’s because the textbounds it’s getting is NaN for some reason.
The only thing that worked was setting the TextLabel with RichText enabled, but due to the number of logs and paragraphs it takes a severe toll on performance, so skipped that.
Hope to see any solution or reasonings why this might happen, thanks!