Request for GuiBase2D:GetScale() or GuiBase2D.ScaleFactor

As a Roblox developer, it is currently too hard to accurately predict the scaling effect of multiple UIScale objects on UI elements. The lack of a straightforward method to determine the absolute scale complicates the process of setting UDim offset properties such as TextSize or Size based on a known AbsoluteSize, etc.

This is especially problematic when creating reusable UI elements (especially ones intended for use by other people), as developers must understand the entire UI hierarchy to accurately predict the resulting sizes and positions.

Currently, the best workaround involves creating a frame, setting its size to an arbitrarily large value, parenting it to the target object, and then calculating the scale based on the resulting AbsoluteSize. This method is neither idiomatic nor efficient:

local f = Instance.new("Frame")
f.Size = UDim2.fromOffset(1000000, 1000000)
local function getScale(object)
    f.Parent = object
    local size = f.AbsoluteSize
    f.Parent = nil
    
    local scale = size/1000000
    return scale.x -- currently assuming that scale is a scalar
end

getScale(frame)

If Roblox is able to address this issue, it would lead to more efficient and intuitive code, making it easier to create reusable and modular UI components, improving my development experience.

Maybe this is the wrong approach, and instead the right approach is to have a read-only property called .Scale.

20 Likes

AbsoluteScale would be a good property name. It could be hard to implement though, so I think it would be easier to add the :GetScale() method!

1 Like