unity 设置屏幕自适应并全屏显示 |
您所在的位置:网站首页 › 怎么设置游戏全屏显示画面 › unity 设置屏幕自适应并全屏显示 |
屏幕自适应
为了程序能够在不同分辨率的显示器中正常显示我们的程序UI界面,我们需要对canvas进行设置: 1、将UI Scale Mode选项中Constant Pixel Size更改为Scale With Screen Size。 2、可以设置Reference Resolution (默认分辨率):可以根据需要是显示的分辨率进行设置,一般横屏设置为19201080;竖屏设置为:10801920。 3、 根据显示需要设置Math:横屏时可以根据确定的高度,适配不确定的显示宽度。可以设置width=0 竖屏时可以根据确定的宽度,适配不确定的显示高度。可以设置hight=1 程序运行时全屏显示1、在Player Setting属性面板中,打开Resolution and Presentation设置选项,将Display Resolution Dialog设置为Disabled 2、新建C#脚本,命名为FullScreen,代码如下 using System.Collections; using System.Collections.Generic; using UnityEngine; public class FullScreen : MonoBehaviour { private void Awake() { //获取设置当前屏幕分辩率 Resolution[] resolutions = Screen.resolutions; //设置当前分辨率 Screen.SetResolution(resolutions[resolutions.Length - 1].width, resolutions[resolutions.Length - 1].height, true); Screen.fullScreen = true; //设置成全屏 } }3、将FullScreen脚本,挂在到场景物体中,最好挂在到摄像机上,便于以后查找。 至此,发布后的程序,运行即可全屏运行显示。 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |