我有一个使用9:16 纵横比 的游戏项目。还有将以“引用分辨率”1080x1920 (9:16)
“随屏幕尺寸缩放”的 Canvas当我构建项目并在“播放器设置”中进行一些设置时,如下所示:
游戏的结果是建立的,总是使用“自由纵横比”。 像这样:
如何只使用我想要的纵横比来构建项目?
谢谢
最佳答案
我在独立构建中也遇到了自定义宽高比的问题。
您可以在start方法中手动设置一次屏幕的宽度和高度。
void Start()
{
Screen.SetResolution(1080, 1920);
}
如果需要,您也可以在游戏运行时更新
private float lastWidth;
private float lastHeight;
void Update()
{
if(lastWidth != Screen.width)
{
Screen.SetResolution(Screen.width, Screen.width * (16f / 9f));
}
else if(lastHeight != Screen.height)
{
Screen.SetResolution(Screen.height * (9f / 16f), Screen.height);
}
lastWidth = Screen.width;
lastHeight = Screen.height;
}
统一文档:
Screen
SetResolution()
关于c# - 如何使用自定义宽高比统一构建项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55204674/