I’m trying to store the current device orientation as a variable, but not sure how, or where to put it in the code (it should be readable by Update to check when the orientation changes). (myDeviceOrientation = Input.deviceOrientation;)
How do I store the current orientation?
C#:
DeviceOrientation originalOrientation = Input.deviceOrientation;
UnityScript:
var originalOrientation : DeviceOrientation = Input.deviceOrientation;
You can declare it globally, so at the top of your JS or C# script where other variables are, simply define it there, like
C#:
public class MyClass : MonoBehaviour
{
private DeviceOrientation originalOrientation;
}
UnityScript:
#pragma strict
var originalOrientation : DeviceOrientation;
then where you choose to set it is up to you, either Update or Start