orientation

Overview

Orientation events occur when the device orientation changes. This means that the orientation event will be triggered even for orientations that the app does not support, with a caveat for Android (see below).

Apps with a fixed orientation, for example "portrait" only, may use the orientation event to rotate the UI manually. However, for apps with multiple supported orientations, the orientation event should not be used to re-layout the UI — instead, the resize event should be used.

This event is also helpful if you're using accelerometer or gyroscope data. This data is relative to portrait orientation, so you can use orientation events to handle the data based on the device's current orientation.

Gotchas

On Android, if your app only supports one orientation in build.settings, the orientation event will still be triggered for all device orientations. However, if your app supports two or more orientations, the orientation event will only be triggered only for the app's supported orientations.

There is a limitation in the Android OS where it will never report an orientation event when flipping between "landscapeRight" and "landscapeLeft", nor will it be reported between "portrait" and "portraitUpsideDown".