UI editor calculates size and position incorrectly

When you select a piece of UI in studio it highlights it such that it shows you guide numbers representing the absolute position (relative to its parent) and the absolute size.

These numbers are wrong. If we take a screenshot of this same image and put it into a photo editor we’ll see that the top right corner starts at (358, 257) and the size is (308, 510).

If you want to reproduce the exact screenshot: The dimensions of the white frame are UDim2.fromScale(0.3, 0.499) centered in an “Actual resolution” 1024 x 1024 emulated device.

Expected behavior

I believe the calculation is simply flooring the values, but as far as I can tell it’s a little more complex than that. Instead, this is how I believe it actually should work.

local function rectFromAbs(position: Vector2, size: Vector2)
	local minX = math.round(position.X)
	local minY = math.round(position.Y)

	local maxX = math.round(position.X + size.X)
	local maxY = math.round(position.Y + size.Y)

	return Rect.new(minX, minY, maxX, maxY)
end
2 Likes

This is just an acknowledgment announcement!

We’ve filed a ticket to our internal database, and we’ll follow up when we have an update!

Thanks for the report!

1 Like