Unity | 获取屏幕工作区的大小

最近做的项目发布后要做自适应,最大化后要铺满全屏(不覆盖任务栏),那么就需要获取工作区的大小,代码如下:

int width = System.Windows.Forms.SystemInformation.WorkingArea.Width;
int height= System.Windows.Forms.SystemInformation.WorkingArea.Height;

Debug.Log(width+","+height);

经测试:

  • 任务栏正常显示的话,工作区宽高为:1920*1040
  • 使用小任务栏按钮的话,工作区宽高为:1920*1050

使用到的dll:(我用的是基于.net4.x的dll,dll下载地址:https://download.csdn.net/download/weixin_39766005/11660884

  • System.Drawing.dll;
  • System.Windows.Forms.dll;
发布了162 篇原创文章 · 获赞 20 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/weixin_39766005/article/details/103187948