Trying to optimise a screen flipping script

Hi guys,
I have this really simple script for flipping the screen when it’s on the phone, but I was thinking there must be a better way to do it. Just seems a shame to have something that happens so infrequently running in an update script.

function Update(){// Keeps the screen in the right orientation

	if (Input.deviceOrientation == DeviceOrientation.LandscapeLeft  iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeLeft){
		iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeLeft;
	}
	if (Input.deviceOrientation == DeviceOrientation.LandscapeRight  iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeRight){
		iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeRight;
	}
	
	if (iPhoneSettings.screenOrientation == iPhoneScreenOrientation.LandscapeLeft)ScreenOrientationState = 1;
	if (iPhoneSettings.screenOrientation == iPhoneScreenOrientation.LandscapeRight)ScreenOrientationState = -1;
}

Or am I worrying about it too much?

Use InvokeRepeating to run that a couple times per frame instead.

–Eric

Wow, I’ve never used that before.
Man, I could definitely apply that to a bunch of other scripts. Thanks!