Screen.currentResolution and Screen.width / Screen.height not working in build.
It’s not working in unity as it might work. In editor everything works perfectly. For example I have a fullHD display and Screen.currentResolution IN EDITOR returns me 1920 * 1080 and Screen.width plus Screen.height return the editor game window resolution 511 * 909. But IN BUILD both of them returns incorrect resolution. For me it’s sometimes 1080 * 1080 that I can’t even define if screen horizontal or vertical. Sometimes it’s 1024 * 768, better but not 1920 * 1080.
What version of Unity are you using? Have you filed a bug report?
I also just submitted a bug report for this. It works on Mac and Unity 4.7. But not for Windows and Unity 5.6.4f
When in a fullscreen window it reports the wrong value for Screen.currentResolution.width and height.
breaking code from Unity 4.7
Is there a workaround to get the screen resolution on windows for C sharp? What I want is when people go into fullscreen mode using alt+enter I used to do:
Screen.setResolution(Screen.currentResolution.width,Screen.currentResolution.height,true)
but now this doesn’t work. Without doing this it just in the wrong resolution with black bars at the sides or top and bottom.
I resolved this problem using C# to get full screen size
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
for desktop builds in windows it works perfectly
2019.1.0.f1. I haven’t filed a bug report, I didn’t think it was a bug in the engine but maybe it is.
I asked that 3 years ago
File a bug report and we can make sure it goes to the right people who can tell you if it’s a bug or not. And fix it if it is
Holy shit I’m a dumbass. I just asked a really similar question and had this open in a tab so I thought it was my question with a bunch of replies.
Having the same issue in Unity 2019.4.17f and was looking for an answer. My screen is 1440p and the editor detects that, but the build only sees 640x480. It’s a bug and has been fixed in recent Unity versions. Unity Issue Tracker - Resolutions returned by Screen.resolutions differ between Editor and Build
Edit 1: Workaround: Instead of Screen.Resolution, use Display.main. For example, Display.main.systemWidth instead of Screen.currentResolution.width.
Answer found here: Screen.currentResolution with Unity 5.2.1 - Stack Overflow
Edit 2: Turns out that the real issue is that Screen.currentResolution.refreshRate returns differently in-editor vs. in-build. In-editor, the refresh rate will be the exact refresh rate of your monitor, say 120Hz. But, in-build, the value will return 119Hz. Therefore, when I was comparing the resolution strings, they were only equal in the editor because of this. So, in-build, the script skipped over my resolution assignment code and defaulted to the dropdown’s first option (640x480). So, ensure you compensate for the difference of 1 somewhere in your code! That fixed it for me.