I’m having a strange and complicated issue using AutomaticSize that doesn’t seem to be listed in the known issues. Bear with me while I try to explain it, because it’s a doozy. The issue is as follows:
The Setup
I have a UIListLayout that is positioning two elements: a TextLabel and an ImageLabel. In the hierarchy, it looks like this:
I have the TextLabel set to be positioned to the left of the image such that this is the result:
The Problem
Now here’s where the problem arises. I want the text to scale properly with screen resolution, so I enable TextScaled. However, I also want to ensure that the icon is displayed immediately to the right of the text with no unnecessary space between them besides the UIListLayout padding.
Quick example of what would be unnecessary space:
To get rid of any unnecessary space, I should be able to set the AutomaticSize property of the text to “X” and let Roblox work its magic for me. However, this does not fix the issue. At a 1280x720 screen resolution, the bounds of the text with TextScaled enabled should be 72x12, which means the expected width of the label itself, with AutomaticSize enabled, should be 72px as well. For some reason, however, this is not the case and the width ends up at 88px.
So let’s dig a little deeper: What happens with TextScaled set to false? Well, the text itself doesn’t scale, but AutomaticSize is calculated properly.
But wait, here’s where things get extremely whacky. Upon setting TextScaled to true, the TextBounds property of the label reads the correct size 72x12, with the label’s size being set to 88x12.
However, upon toggling the “Visible” property of the label to false, then back to true, the TextBounds property will mysteriously update to read “88x15”, without the size of the label actually changing at all.
Now I’m just spitballing here, but something tells me that the automatic size system and the text scaling system each have their own idea of what the actual size of the text (or the text label) is. I say this because the 88px width that Roblox thinks the text is being displayed at would actually be correct if the AutomaticSize was set to XY and not just X, as seen here:
So yeah, this has been an extremely frustrating bug to deal with (and even explain) and I hope it can be fixed soon!