unity--设置默认屏幕方向并支持自动旋转

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lalate/article/details/84029536

1.在Player Setting里面设置默认的启动屏幕正方向:

2.在控制类的Awake或者Start方法里面,再设置想要的旋转方向

1

2

3

4

5

6

7

8

9

void Awake()

{

    //设置屏幕自动旋转, 并设置支持的方向

    Screen.orientation = ScreenOrientation.AutoRotation;

    Screen.autorotateToLandscapeLeft = true;

    Screen.autorotateToLandscapeRight = true;

    Screen.autorotateToPortrait = false;

    Screen.autorotateToPortraitUpsideDown = false;

}

猜你喜欢

转载自blog.csdn.net/lalate/article/details/84029536