I’m trying to create a GUI for my game but I’ve ran into an issue. It seems like the values for Screen.width and Screen.height are reversed when played on the Iphone vs the editor.
Even the docs state vertical orientation screen is treated as 480x320 for iPhone and horizontal orientation as 320x480 for iPhone.
Isn’t that the opposite of what it should be? Shouldn’t horizontal be 480x320?
In the editor Screen.width = 480
On the iphone Screen.width = 320
The editor is set to Iphone Wide and the default orientation is landscape.
not sure if a typo but a known thing that you should not use such stuff in there as the static initializers are called very early.
In U2 / IPHone 1.x it was no problem but in U3 it seems like screen gets filled with the correct data very late actually
Unity 3.0/3.1 has a bug with Maximize On Play, where the values are incorrect for the first couple of frames. If you don’t use that (and outside the editor), there’s no problem.
I have also seen issues with requesting Screen.width and Screen.height. I now add a 1-2 frame pause after waking up to ensure that these values have been set correctly. I had issues where the width/height would give me all sorts of crazy values - completely bogus.
According to other threads, this is even worse in 3.5.2.
it’s better to use “camera.pixelWidth” and “camera.pixelHeight” instead of screen.width/screen.height. Camera.pixelWidth works perfectly for me… no issues.
ios 7 at the first frame
it might totally happen. on pre-ios8 (unless iirc you force orientation) it starts in portrait and then is rotated. and we do start frame a bit too early for lots of reasons.