- Home /
Screen.width not returning the right values
My computer screen resolution is 1920x1080. So if I use Screen.width, it should return 1920, right?
However, when I enter it into my script, it returns 416 instead. Any one has any idea why this is so?
boxWidth = Screen.width*0.25f, //Width of GUI background box
This is suppose to be the width of my GUI box, but it shows 104 instead of the expected value, 480.
I assume you have set the Unity resolution to 1920x1080?
I created a project and tried it out with your code and I get a result of 408.75. If I build the project and run it, I get 480 as a result. Not sure if there is a bug or a way around it but it looks like you'll have to test build fairly often.
Answer by Doireth · Feb 02, 2013 at 12:04 AM
Screen.width
returns the width of the game's view and not the actual screen itself.
Correct. For the Desktop resolution, try Screen.currentResolution ins$$anonymous$$d.
Answer by iwaldrop · Feb 01, 2013 at 11:38 PM
Probably because the size of your Game view is in Free Aspect and it isn't being maximized on play.
Your answer
Follow this Question
Related Questions
full screen wide GUI.Box 3 Answers
Filling the screen doesn't... 1 Answer
Android Button Screen 1 Answer
How can I get a UI Panel's size in relation to the screen size? 1 Answer
Developing a Dynamic GUI 1 Answer