Screen orientation change notification


Is is possible for my script to be notified at the moment the device changes orientation? I’d rather not keep testing for device orientation on each frame… Maybe there’s something like the delegate protocols in Obj-C, but no amount of searching or looking through the docs has helped.

Any help much appreciated!

I figured it out using UnitySendMessage - in Xcode, in “”, in -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation I added:

NSString *theOrientation = [NSString stringWithFormat:@"%i", interfaceOrientation];
UnitySendMessage("Game Manager", "DeviceRotated", [theOrientation UTF8String]);

and in Unity, in the script on my Game Manager gameObject I added -

public void DeviceRotated(string theMessage) {

    // do something here which needs to be done when device orientation changes


Being new to Unity I hadn’t realised there could be 2-way communication between Unity & the Obj-c stuff. Probably elementary to most people here, but I thought I’d post it in case it helps someone avoid the troubles I had.