Is there a way to do this? So that the image’s rounded corners will maintain the ratio on all screen sizes, since a 5 pixel round would be a lot more noticeable on a phone than a 26" monitor.
I know I can do this dynamically by detecting screen size and setting image and 9 slice based on that but maybe there is an easier way.
There doesn’t seem to be any way to do this unfortunately. You will need to do it manually.
On the bright side, if you’re only using one image you can use the SliceScale property so you don’t need to do as much logic (a moot benefit tbh, but it can be an easy one-liner like SliceScale = size_y * slice_scale_factor).
You can accomplish something like what you’re suggesting with a method like this (I’ve never actually have much reason to do this before so my code might not be the best solution or even work lol, but it’s got the idea):
local images = { -- ascending order to vertical screen size (<= threshold, use that image)
{threshold = 720, image = 00000, slice_center = Rect.new(25, 25, 75, 75)},
{threshold = 1080, image = 00000, slice_center = Rect.new(50, 50, 150, 150)}
}
local size_y = workspace.CurrentCamera.ViewportSize.Y
local selected_image
for i = 1, #images do
if size_y <= images[i].threshold then
selected_image = images[i]
break
end
end
if not selected_image then
selected_image = images[#images]
end
image_label.Image = "rbxassetid://"..selected_image.image
image_label.SliceCenter = selected_image.slice_center