Unity 4.6-如何针对每种分辨率将GUI元素缩放到合适的大小 [英] Unity 4.6 - How to scale GUI elements to the right size for every resolution

查看:331
本文介绍了Unity 4.6-如何针对每种分辨率将GUI元素缩放到合适的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的Unity 4.6带有新的GUI,当我在Unity上更改分辨率时,UI Button可以完美缩放,但是当我在Nexus 7设备上进行测试时,Button看起来太小。知道如何解决这个问题吗?

The new Unity 4.6 comes with a new GUI, when I change de resolution on Unity the UI Button scales perfectly but when I test on the Nexus 7 device the Button looks too small. Any idea how to solve this?

推荐答案

Unity的新GUI系统使用锚来控制gui元素(如按钮)相对于其父容器的缩放比例。

Unity's new GUI system uses "anchors" to control how gui elements (like buttons) scale in relation to their parent container.

Unity在此处提供了有关如何使用新的 Rect Transform组件(已配置锚点)的教程视频: http://unity3d.com/learn/tutorials/modules/beginner/ui/rect-transform

Unity has a tutorial video on how to use the new "Rect Transform" component (where the anchors are configured) here: http://unity3d.com/learn/tutorials/modules/beginner/ui/rect-transform.

教程的后半部分全部关于锚点。该页面具有指向整个教程系列的链接。不会太久。您应该注意整个问题。

The last half of the tutorial is all about anchors. That page has links to the entire tutorial series. It's not too long. You should watch the whole thing.

特定于您的问题:

锚点在您的第一个屏幕上可见射击。它们是按钮左上方的四个小箭头。

The anchors are visible in your first screen shot. They are those 4 little arrows at the top left of your button.

现在,您的按钮仅锚定在按钮的左上角。

Right now, your button is only anchored by it's top left corner.

需要向右拖动两个右锚点,以便将按钮的右边缘锚定到其父容器内的空间。

The two right anchors need to be dragged to the right so that the right edge of your button is anchored to a space inside its parent container.

根据您的情况,可能需要向下拖动两个底部箭头,以便同时固定按钮的底部边缘。

Depending on your situation, the two bottom arrows may need to be dragged down so that the bottom edge of your button is anchored as well.

我上面链接的视频

最后,为使字体大小在不同分辨率下能很好地缩放,您需要在基准画布的基础画布上添加并配置参考分辨率组件。您的用户界面,如Ash-Bash32先前所述。

Lastly, for the font size to scale nicely on different resolutions, you will need to add and configure a reference resolution component to the base canvas of your UI, as Ash-Bash32 wrote earlier.

更新:添加参考分辨率组件的最佳方法是通过检查器窗口

Update: The best way to add a Reference Resolution component is through the inspector window for the base canvas in your UI.

1)单击检查器底部的添加组件按钮。

1) click the "Add Component Button" at the bottom of the inspector.

2)在搜索过滤器字段中输入单词 Reference。

2) type the word "Reference" in the search filter field.

3)在搜索结果。

这篇关于Unity 4.6-如何针对每种分辨率将GUI元素缩放到合适的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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