I currently have a GUI that is fixed to these default dimensions: 640 by 400.
I want to upscale and downscale this GUI the same way UIScale works based on the players current screen size / resolution. There should always be empty space at the top and at the bottom like so:
What you are using is Offset, it wont change according to screen size, use scale instead
With scale, the value 1 will cover up the whole axis, so just play with values between 1 and 0
if you dont want to play with values, I recommend you get this plugin.
I have tried using UIAspectRatioContraint and it does not work properly. I have to set it to 1.6 to even keep the original size and when I try it on different screen size it does not even take bordersize into account.
But using UIAspectRatioConstraint does not even work in the first place, my GUI is now a square and notice how it doesn’t stay properly inside the screen either:
Its a square because it doesnt have the right aspect ratio, also it probably doesnt fill the screen right because the scale of the UI is 1 on the Y axis, this GUI has the size set to {.4, 0}, {.4, 0}
I got the plugin and tried it out and while I got it to work visually the way I wanted it to, technically this is not a feasible solution in my specific case.
The reason why I need to use UIScale here is because this UI has thousands of inner Frames that also need to scale along with the canvas.
Issue The GUI here works as intended, but not the contents:
This is with UIScaling, but the original issue still remains :
Is there anything else you can think of that would make this work the same way without having me script it?
UIScaling also seems to stretch the border correctly.
While this does visually solve the GUI issue that I originally asked, it does not scale child instances and the border stays the same size.
I’ve now made a script that does what I want:
local camera = workspace.CurrentCamera
local canvasWidth = script.Parent.Parent.Size.X.Offset
local function scale()
local screenSize = camera.ViewportSize
local smallest = screenSize.X
if screenSize.Y < smallest then
smallest = screenSize.Y
end
script.Parent.Scale = (smallest / canvasWidth) / 1.2
end
-- Setup for the first time:
scale()
camera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
scale()
end)
I want to thank everyone for participating though and providing me answers that visually solved the problem to a certain degree. I appreciate it a lot.