How to get window resolution in windowed mode (not fullscreen)
When I switch game in window mode, i would like to get the resolution of that window. I tried Screen.width and Screen.heigh, but it gives me the resolution of whole screen, not just that game window. How can I get the game window resolution in windowed mode?
Thank you.
Answer by martinhadzhiev · Jun 07, 2021 at 10:27 AM
I encountered the same problem when in windowed mode and decided to experiment a little with the Screen properties. Here is what I found :
Screen.currentResolution.width && Screen.currentResolution.height returns the resolution of the screen
Screen.width && Screen.height returns the resolution of the window
Answer by Ural · Aug 28, 2016 at 10:28 AM
Screen.height and Screen.width gives the actual height/width of the player window, as it seys in the documentaion. If you start in full screen whit a set resolution e.g. of 1600x900 on a screen whit reselutoin 1920x1080 it will scale down the reseluton of the screen to the player window reselution, thus when switching to window mode the screen "goes back" to its original reselution makeing the window mode take up a smaller part of the screen but still it will have its orginal resolution of 1600x900.
Can this be the case? Or other thin I can think of is if you dont call the Sceen.height/ Sceen.width but save them in a variable that is not updated. Hope this helps
I'd disagree. I tried by debugging the current resolution and i get the native resolution of my pc instead of the current window set in the Game Tab
Your answer
Follow this Question
Related Questions
Resolution messed up after switching between fullscreen modes. 1 Answer
Game showing black borders 2 Answers
Switch to maximized window at runtime 0 Answers
How To Change GameObject Position Base On Screen Size? 1 Answer
What is the best/easiest method to scale a 2D mobile game to all screen sizes? 0 Answers