Unity 手機遊戲屏幕翻轉/轉屏問題

打包時的屏幕翻轉設置

上述圖片代表在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;
    }
}

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章