As the title says, I want to resize the window while maintaining the aspect ratio in a resizable window.
I created a GameObject with the following code attached, but when I drag the window, the size changes are not smooth, and it stutters.
My settings are as follows. Any advice would be greatly appreciated.
Thank you.
int width = Screen.width;
int height = Screen.height;
if (lastWidth != width)
{
float heightAccordingToWidth = (float)width / 16.0 * 9.0;
Screen.SetResolution(width, (int)Mathf.Round(heightAccordingToWidth), false, 0);
}
else if (lastHeight != height)
{
float widthAccordingToHeight = (float)height / 9.0 * 16.0;
Screen.SetResolution((int)Mathf.Round(widthAccordingToHeight), height, false, 0);
}
lastWidth = width;
lastHeight = height;