The description for Screen.currentResolution says, “if the player is running in window mode, this returns the current resolution of the desktop.”
So my code reads:
deskW = Screen.currentResolution.width;
deskH = Screen.currentResolution.height;
But it’s returning values of 640 and 480, which is 4:3, yet my desktop is set to 1680x1050 (16:10).
640x480 is, of course, the first resolution the monitor is capable of supporting. Thinking it might have been reporting the closest possible desktop to the current Screen.width (?), I tried scaling the Unity window around - yet even if my Screen.width climbs above the next highest resolution my monitor supports, deskW and deskH still return 640x480.
As a newbie I know I’m just missing something here…please help me out if you see my mistake.
Any help is much appreciated~!
bOB
I guess if you are running in the editor it will always output that screen res.
I could be wrong though
Ray
yellowlabrador, Is correct: The only resolution Unity runs in or “sees” while in the editor is 640x480.
Also note, that while running in the editor, the only resolution contained within Screen.resolutions is “640x480”
Got it. Thanks for clearing that up. I’ll have to display it on screen at runtime until I’ve ensured I’m using it correctly. Or can you recommend a better way?
BTW, does anyone know if there’s a reason for this behavior, or is it just one of those “it can’t work that way” type of things you just have to learn by experience? I’d love a logical explanation if there is one - some sense of closure for the time I spent chasing this.
Also, is that documented somewhere that I missed?
A nice place would be in the manual under Scripting>Runtime Classes>Screen: static var currentResolution.:idea:
Something like, “Please Note: when running in the editor Screen.currentResolution will only return 640 x 480 @60 hertz.”
Thanks again~!
bOB
and still more than a year on it took this post to clear this up for me… its not the most intuitive result if you try and log out currentResolution and receive the wrong value???
Just out of curiosity, try running in editor, but full screen mode and see what you get.