void Update () {
//处理横向两个方向旋转
if(Input.deviceOrientation == DeviceOrientation.LandscapeLeft)
{
if (Screen.orientation != ScreenOrientation.LandscapeLeft) {
Screen.orientation = ScreenOrientation.LandscapeLeft;
}
}else if(Input.deviceOrientation == DeviceOrientation.LandscapeRight)
{
if (Screen.orientation != ScreenOrientation.LandscapeRight) {
Screen.orientation = ScreenOrientation.LandscapeRight;
}
}else
//处理纵向两个方向的旋转
if(Input.deviceOrientation == DeviceOrientation.Portrait)
{
if (Screen.orientation != ScreenOrientation.Portrait) {
Screen.orientation = ScreenOrientation.Portrait;
}
}else if(Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown)
{
if (Screen.orientation != ScreenOrientation.PortraitUpsideDown) {
Screen.orientation = ScreenOrientation.PortraitUpsideDown;
}
}
}