Unity设置横竖屏

使用开发工具设置(工程统一设置)

在这里插入图片描述

在这里插入图片描述

使用代码设置(可以分开设置不同场景)

竖屏
Screen.orientation = ScreenOrientation.Portrait;
Screen.autorotateToPortrait = true;
Screen.autorotateToPortraitUpsideDown = true;
Screen.autorotateToLandscapeLeft = false;
Screen.autorotateToLandscapeRight = false;
横屏 Screen.orientation = ScreenOrientation.AutoRotation; Screen.autorotateToPortrait = false; Screen.autorotateToPortraitUpsideDown = false; Screen.autorotateToLandscapeLeft = true; Screen.autorotateToLandscapeRight = true;