- Home /
Correct way of obtaining screen resolution
I'm currently designing a game for Android that places GameObjects in a script relative to the Screen width and Screen height. I have set the resolution in my Player to be 1920x1080 (resolution of a Galaxy S4), but calling "Screen.width" and "Screen.height" return 855 and 481 respectively.
These seem to be the current size of the actual player, but not the resolution dimensions, which is what is required for playing on a mobile device. What is the correct way to get the resolution width and height? Or, I guess a better question would be, how can I make the player simulate a 1920x1080 display?
Thanks!
Answer by Owen-Reynolds · Mar 12, 2014 at 10:32 PM
I don't think there's a problem. I believe Screen.Width/Height, as you note, always gives the actual game window size. On mobile, that will always be the full size of the device.
In the editor or non-full-screen desktop, you want the current window size. For example, width/2 is always the center of the current window (if it was the center of the physical computer screen, even as you moved the window around, that would be odd.)
For question #2, 1920 by 1080 is a 16:9 ratio. So pick that in the Unity Game window.
So, you did answer my question :), turns out the resolution was right. I was doing GameObject placement manually, and I guess it got a little screwy going over to the phone. I am now placing objects with ScreenToWorldPoint, and everything is working great. Thanks!
Answer by jahlive1951 · Mar 12, 2014 at 10:56 PM
Where to set resolution on unity 4.3.3f1 as I can find the terren on the tool bar
Your answer
