上述圖片代表在Plyer Seettings設置中禁止翻轉,使用的是Unity5.3版本
下面是代買修改屏幕是否可翻轉。
using UnityEngine;
using System.Collections;
/// <summary>
/// 手機屏幕翻轉問題
/// 2016.11.12
/// </summary>
public class CellphoneOrientation : MonoBehaviour
{
void Awake()
{
/// 如果在發佈遊戲包的時候,在playerSetting中設置了禁止屏幕翻轉,但是代碼中設置屏幕是可自動翻轉,則遊戲發佈出來後,任然是可翻轉的。
Screen.orientation = ScreenOrientation.AutoRotation;
/// 下面幾個bool值設置了是否可以翻轉到某個方向。false代表是禁止
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
Screen.autorotateToPortrait = true;
Screen.autorotateToPortraitUpsideDown = true;
}
}