- Home /
Screen.currentResolution with Unity 5.2.1
We are using unity to develop a desktop application, and we were using Unity 4 previously. Now we have upgraded our project to Unity 5 (5.2.1). We have an issue with setting the screen resolution. We used Screen.SetResolution (Screen.currentResolution.width, Screen.currentResolution.height, true);
in Unity 4 to set the resolution and it works fine. But in unity5 Screen.currentResolution.width
doesn't gives the correct value. Is there anything new with Unity 5.2.1 ?
What do you mean by "doesn't give the correct value"? Always 0? Some random value?
According to the documentation:
The current screen resolution (Read Only).
If the player is running in window mode, this returns the current resolution of the desktop.
From your code I suppose you're setting your game to fullscreen, so, currentResolution should return the native resolution but it isn't?
Also, maybe it's important to tell what's the platform you're building for.
Did you ever find a solution? This appears to be a but in Unity 5
Answer by Halichoerus · Oct 14, 2015 at 05:50 PM
Same thing happened to me, I just used Screen.width and Screen.height to get the current resolutions, and Screen.resolutions for a list of supported full screen resolutions (last element in the array being the largest).
This should work for you, you can even cycle though this array in your options menu so the player can adjust resolution.
Resolution[] allRes = Screen.resolutions;
Screen.SetResolution(allRes[allRes.Length-1].width, allRes[allRes.Length - 1].height, true);
Your answer
Follow this Question
Related Questions
size of window 0 Answers
Screen Resolution -1 Answers
How to disable object scaling when screen height is changing 0 Answers
Screen.currentResolution values don't change after SetResolution in Mac builds 1 Answer
I have problems with the Camera.ortographic to adapt the view to screens with different resolutions. 2 Answers