Hello I am trying to scale UI elements that have a UIListLayout affecting them. I can scale fine, but when I do the other elements scale and move to accommodate the size of the scaled one. I don’t want that. I know I could just not use UIListLayouts, but they make the workflow much easier.
Video of the issue:
Relevant code (if it matters):
local DEFAULT_TEXT_TRANSPARENCY = 0.6
local textElement: TextButton | TextLabel = (findFirstDescendantWhichIsA(uiElement, "TextLabel") or findFirstDescendantWhichIsA(uiElement, "TextButton"))
if textElement and not textElement:HasTag("CustomTextTransparency") then
textElement.TextTransparency = DEFAULT_TEXT_TRANSPARENCY
end
if uiElement:HasTag("Button") then
local hoverColor = uiElement:GetAttribute("HoverColor") or Color3.fromRGB(150, 150, 150)
local originalColor = uiElement.BackgroundColor3
local originalSize = uiElement.Size
local originalTransparency = textElement and textElement.TextTransparency
uiElement.MouseEnter:Connect(function()
TS:Create(uiElement, hoverInfo, {Size = uiElement.Size + UDim2.fromScale(uiElement.Size.X.Scale * 0.05, uiElement.Size.Y.Scale * 0.05)}):Play()
if textElement then
TS:Create(textElement, hoverInfo, {TextTransparency = 0.1}):Play()
end
end)
uiElement.MouseLeave:Connect(function()
TS:Create(uiElement, hoverInfo, {Size = originalSize}):Play()
if textElement then
TS:Create(textElement, hoverInfo, {TextTransparency = originalTransparency}):Play()
end
end)
end
Thanks.