Haven’t come across that one before, I work on Vista 64 Ultimate.
Is this running at full screen, or windowed in the editor you get this issue? Also check the stats display if you are working in the editor and see what it’s width is displaying.
That is strange. I’d give the usual “Latest Graphics Drivers” advice, and also try to pin down what else happened when you switch to using the other text editor. Maybe it was a recompile of the scripts that triggered it to work or something like that.
Screen.width and Screen.height doesn’t return the resolution the user/developer picked, but the actual window/screen size.
Are you stretching the editor’s game window? That could be the cause.
When you are checking it, are you checking during the Start() or in Update() ? If youre checking in Start() you will get the screen width in the editor at the time you pressed play. If you check it during Update() you will get the width even if you stretch it.
For me, it’s returning the same number no matter what resolution. Screen.height is working properly, but not Screen.width. The variable set as public, so it shows in the inspector.
There is a known bug that occurs when a project is run in the editor - the correct value of Screen.width and Screen.height don’t get set until a few frames into execution. As far as we know, it doesn’t happen in built applications or webplayers but it can be a bit of a nuisance during development.
Correct – I have noticed this. I am currently developing a game for the web with a set resolution. Luckily the resolution is small, 800 x 450 or something, meaning it can fit on all of my screen at once. If I press play while in scene mode (AKA, where you “build your world”), my GUI gets messed up because Unity gets the screen resolution before game mode (where you play your game in the editor) fully starts.
My suggestion would be use a low resolution in the editor, manually click on the game mode tab and then press play. I was tearing my hair out until someone at Unity support told me this. Hope it gets fixed in the next patch.
I know this is an old thread but I was having the same problem so hopefully this can help someone.
I was trying to get the Screen.width and Screen.height in editor mode and it was being reported wrong. I was able to get around this by using ExecuteInEditMode and checking the screen dimensions in the Update() loop and it appears to work fine.