I have a game project that uses a 9:16 aspect ratio. And also the canvas that will "Scale with Screen Size" with "Reference Resolution" 1080x1920 (9:16)
When I build the project and give some settings in "Player Settings" like this:
The results of the game are built, always just use "Free Aspect Ratio". Like this:
How can I build a project using only the aspect ratio that I want?
Thank you
To do so, go to Edit | Project Settings | Player. Your Inspector should now display the following: You may have more or fewer platforms displayed here; it depends on the modules you have installed with Unity. To force a specific resolution on a PC, Mac, & Linux Standalone game, deselect Default is Native Resolution.
I've had trouble getting custom aspect ratios in standalone builds as well.
You can set the screen width and height manually once in the start method.
void Start()
{
Screen.SetResolution(1080, 1920);
}
If need be, you can also update it while the game is running
private float lastWidth;
private float lastHeight;
void Update()
{
if(lastWidth != Screen.width)
{
Screen.SetResolution(Screen.width, Screen.width * (16f / 9f));
}
else if(lastHeight != Screen.height)
{
Screen.SetResolution(Screen.height * (9f / 16f), Screen.height);
}
lastWidth = Screen.width;
lastHeight = Screen.height;
}
Unity Doc:
Screen
SetResolution()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With