Testing orthographic camera at various resolutions to test dynamic layouts – and while I can configure the camera at start, is there any kind of event I can listen to to detect a change in screen resolution so I can modify my layout? Polling the resolution in an update seems like a poor solution.
2 Answers
2Screen.width, Screen.height
if you check it every half a second, and it will still be very fast, and it will use 1/12000 of your processor power instead of 1/2000th.
On Mobile, I’m using Screen.orientation to simply detect orientation change.
I’m doing it in a Singleton Class with an event, that any other script can subscribe to, so that it’s all in one place and doesn’t cost too much.
if (Screen.orientation != screenOrientation)
{
if (ScreenOrientationChanged != null)
ScreenOrientationChanged () ;
}
Yet, having an editor callback would be nice.