Unity设置横竖屏

时间:2024-03-15 14:51:57

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

Unity设置横竖屏

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;