为多种分辨率/不同设备缩放 UI [英] Scale UI for multiple resolutions/different devices

查看:35
本文介绍了为多种分辨率/不同设备缩放 UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的统一图形用户界面,它具有以下方案:

I have a quite simple unity GUI that has the following scheme :

Brekt 和按钮在哪里.

Where Brekt and so are buttons.

GUI 在 PC 上运行良好,并且位于 屏幕空间:覆盖,因此它应该自动适应以适应每个屏幕.

The GUI works just fine on PC and is on screen space : overlay so it is supposed to be adapted automatically to fit every screen.

但在平板电脑上,整个 GUI 更小,屏幕中央也缩小了,元素周围有很大的边距(现在无法加入屏幕截图)

But on tablet the whole GUI is smaller and reduced in the center of the screen, with huge margins around the elements (can't join a screenshot now)

有什么办法可以解决这个问题?是在播放器设置中还是在项目设置中?

What is the way to fix that? Is it something in player settings or in project settings?

推荐答案

自动缩放 UI 需要结合使用 RecTransform 的锚点、枢轴点和 Canvas Scaler 组件.如果没有图像或视频,很难理解它.彻底了解如何执行此操作非常重要,Unity 为此提供了完整的视频教程.您可以观看 此处.

Automatically scaling the UI requires using combination of anchor,pivot point of RecTransform and the Canvas Scaler component. It is hard to understand it without images or videos. It is very important that you thoroughly understand how to do this and Unity provided full video tutorial for this.You can watch it here.

此外,当使用滚动条、滚动视图和其他类似的 UI 控件时,ContentSizeFitter 组件也用于确保它们适合该布局.

Also, when using scrollbar, scrollview and other similar UI controls, the ContentSizeFitter component is also used to make sure they fit in that layout.

这篇关于为多种分辨率/不同设备缩放 UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆