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;
    }
}

 

 

 

 

 

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