- Home /
Get correct resolution
After many many tries and months of struggle and nonsense, anyone knowns how to get the current display resolution? Don't understand why it's so difficult :/
I know using Screen.currentResolution.width works for windows mode where I'll get the correct screen resolution even if I move the game window to a different screen, but fails in full screen mode. Anyone knows the answer to this?
Looks like this is impossible to my knowledge which is rather weird, many people use a similar workaround for this.
I basically use something like this where I put the game in windowed mode, wait 0.1 seconds, then apply the resolution using Screen.currentResolution as you get the actual desktop resolution regardless of game window size or even if you move it on a different screen mid game:
Screen.fullScreen = false;
yield WaitForSecondsRealtime(0.1f);
var r : Resolution = Screen.currentResolution;
Screen.SetResolution (r.height/0.75f, r.height, false);
//Re-apply fullscreen mode if needed
I don't know how to get to it but the resolution in full-screen is hidden in the Screen.width property.
When you look up Screen.width in the documentation it says: "in full-screen it is also the current resolution". The same is written in the Screen.height documentation. And I recall using Screen.Width / Screen.Height once and the result weirdly was 1, albeit the actual width being 2048p and height 1012p or something. I expected the answer to be 1.6 anyhow. So somewhere hidden in there is the actual resolution.
Could be wrong but I think Screen.width return something like the store resolution that's automatically save for your game in the registry. So not a very useful variable.