- Home /
Question by
THUNDER_WOLF10 · Aug 18, 2021 at 08:54 PM ·
resolutionscreenmobile devicesscreen size
Settings display aspect ratio through code
Hello, I want to change the screen ratio for my mobile game through code(like you can change before running game in the resolution tab as shown in the picture) like this:
void Start(){
var res = Screen.currentResolution;
float ratio = (float)res.width/res.height;
print(ratio);
SetAspectRatio(ratio);
}
For some reason, I can't find how to change it with code
aspectratio.png
(3.6 kB)
Comment
Your answer
Follow this Question
Related Questions
Fitting Into Different Screens 0 Answers
Resolutions and pixel perfect in 2D 0 Answers
Change main camera size depending on screen size 1 Answer
Its possible to open a mobile app in windows mode by default 0 Answers
Make buttons visible in the editor? 2 Answers