When AutomaticSize for a StyleRule is set to nil
or Enum.AutomaticSize.None
the existing UI Elements of which the rule is applied to are not updated to reflect this change.
reproduction:
local Gui = Instance.new("ScreenGui")
Gui.Parent = game:GetService("RunService"):IsServer() and
game:GetService("StarterGui") or
game:GetService("Players").LocalPlayer.PlayerGui
local Sheet = Instance.new("StyleSheet")
Sheet.Parent = Gui
local Rule = Instance.new("StyleRule")
Rule.Selector = "TextButton"
Rule:SetProperties({
Position = UDim2.fromScale(.5, .5),
AnchorPoint = Vector2.new(.5, .5),
AutomaticSize = Enum.AutomaticSize.XY
})
Rule.Parent = Sheet
local Link = Instance.new("StyleLink")
Link.StyleSheet = Sheet
Link.Parent = Gui
local Btn = Instance.new("TextButton")
Btn.Parent = Gui
task.wait(2)
print("Setting AutomaticSize to `X`.")
Rule:SetProperty("AutomaticSize", Enum.AutomaticSize.X)
task.wait(2)
print("Setting AutomaticSize to `None`.")
Rule:SetProperty("AutomaticSize", Enum.AutomaticSize.None) -- This doesn't work.
task.wait(2)
print("Setting AutomaticSize to `Y`.")
Rule:SetProperty("AutomaticSize", Enum.AutomaticSize.Y)
task.wait(2)
print("Setting AutomaticSize to `nil`.")
Rule:SetProperty("AutomaticSize", nil) -- This doesn't work.
The code above will cycle through all of the enum items for AutomaticSize and apply them to the style sheet.
Expected behavior
I would expect that setting the AutomaticSize
property to either nil
or Enum.AutomaticSize.None
would retroactively update the instances the StyleRule is attached to.