How to optimize UICorner and UIStroke for all device?

Hi everyone, I don’t know how to optimize UICorner and UIStroke for all devices. Anyone who helps will be very grateful!


Just use the scale property of UICorner. For the UIStroke, I’m not sure how to fix that.

1 Like

As @purpledanx mentioned you should use the scale property for UICorners, however for UIStrokes you can use a script like this:

local base_resolution = Vector2.new(1920, 1080) -- Change this to your resolution when making the UIStroke, can be found through Camera -> ViewportSize
local base_size = script.Parent.Thickness -- Base UIStroke size

local cam = workspace.Camera

local function rescale()
   local diff = (cam.ViewportSize / base_resolution).Magnitude
   script.Parent.Thickness = base_size * diff
end

rescale()

cam:GetPropertyChangedSignal("ViewportSize"):Connect(rescale)

This script will dynamically resize the UIStroke, make sure to change base_resolution to your viewport size though.

Thank you so much bro! You saved me a couple of days!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.