Skip to main content

屏幕相关属性

1、静态属性
(1)常用

// 当前分辨率(自己设备的分辨率)

Rosolution r = Screen.currentResolution;

当前屏幕分辨率的宽、高:r.width/r.height
// 屏幕窗口当前宽高(Game窗口的宽高),一般写代码要用Game窗口宽高调试

Screen.width/Screen.height
// 屏幕休眠模式

Screen.sleepTimeout = SleepTimeout.NeverSleep / SleepTimeout.SystemSetting(不息屏/系统设置)
(2)不常用

// 运行时是否全屏模式

Screen.fullScreen = true;
// 窗口模式

独占全屏 FullSceenMode.ExclusiveFullScreen
全屏窗口 FullSceenMode.FullScreenWindow
最大化窗口 FullScreenMode.MaximizedWindow
窗口模式 FullSceenMode.windowed
Screen.fullScreenMode = FullSceenMode.windowed
// 移动设备屏幕转向相关

// 允许自动旋转为左横向, Home键在左

Screen.autorotateToLandscapeLeft = true;
// 允许自动旋转为右横向, Home键在右

Screen.autorotateToLandscapeRight = true;
// 允许自动旋转到纵向, Home键在下

Screen.autorotateToPortrait = true;
// 允许自动旋转到纵向反方向, Home键在上

Screen.autorotateToPortraitUpsideDown = true;
// 指定屏幕显示方向,ScreenOrientation.***

Screen.orientation = ScreenOrientation.Landscape(横屏)
2、静态方法
// 设置分辨率,一般移动设备不使用

// 参数三:是否全屏

Screen.SetResolution(1920,1080,false);