- Home /
How to change screen size with aspect ratio? C#
I'm wondering how I would get the screen resolution to change with the aspect ratio. For example if I start the game with a 4:3 aspect ratio with a 1280x960 resolution and you change the aspect ratio to 16:9 it would change to 1280x720. I've got changing the aspect ratio right(I think) but when I try it in standalone the screen resolution stays the same but the aspect ratio changes.
Here is my code:
public void fourthree() //4:3 Aspect Ratio
{
camera.aspect = 4f / 3f;
}
public void sixnine() //16:9 Aspect Ratio
{
camera.aspect = 16f / 9f;
}
The code is activated via the UI Buttons.
Also to keep my game from crashing how would I make sure the resolution doesn't surpass the possible screen resolution and aspect ratio the monitor can handle?
This is all planned to happen in game. I won't be using the Unity Dialog.
Your answer
Follow this Question
Related Questions
Textures looks very poor in unity than in Maya 0 Answers
In Game Graphics/Resolution Options 2 Answers
Can I change Terrain resolution when zooming out 2 Answers
Pixel Perfect and Forced Aspect ratio 0 Answers