实际上,fontSize在Unity中是什么意思? [英] What does actually fontSize mean in Unity?

查看:505
本文介绍了实际上,fontSize在Unity中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Unity Android/iOS应用程序.我需要显示尺寸与屏幕尺寸和密度有关的文本. 材料设计指南说,我应该将常规文本的大小设置为14sp.我该如何提供?

I'm developing Unity Android/iOS application. I need to show text with size relative to screen size and density. Material design guide says I should set size of my regular text to 14sp. How can I provide it?

fontSize在Text组件中实际上意味着什么?这个数字取决于什么吗? Unity文档 fontSize的描述对此一无所知.

What does actually fontSize mean in Text component? Is this number dependent on something? Unity Documentation description of fontSize says nothing about that.

感谢您的答复.

推荐答案

因此...字体大小在Unity中的三个位置基本上是定义"的.

So... Font Size is essentially "defined" in three places in Unity.

第一个是字体资产本身(导入设置).据我最近能够确定的(Unity 4.5之后),该值未使用(我将其调整为疯狂的值,并且对屏幕上显示的内容没有任何影响;我在Unity 3.5中知道这一点)影响了字体的最终呈现,我不得不将其放大得非常大才能获得清晰的呈现文本,因为这实际上是可用的最大字体大小",并且大于此值的字体大小(请参阅#2)会变得模糊).

The first is on the font asset itself (the import settings). As far as I've been able to determine lately (post-Unity 4.5), this value is not used (I've tweaked it to insane values and had no affect on what is displayed on-screen; I know in Unity 3.5 this affected the final rendering of the font and I had to scale it up really big to get nice, cleanly rendered text, as it was effectively the "maximum font size available" and font sizes larger than this value (see #2) would get blurry).

第二个是在文本组件上,称为Font Size,它可以完成所说的操作.就像在任何应用程序中选择较大的字体一样.这就是材料设计指南所指的. Unity中的文本组件字体大小以高度像素"为单位,与屏幕像素的比例为1:1(除非缩放转换(或其任何父转换)或缩放画布本身在Worldspace中,您一定要猜哪种情况)).

The second is on the text component, called Font Size which does what it says. It's like picking a larger font size in any application. This is what the material design guide is referring to. Text component font sizes in Unity are measured in "pixels of height" and are 1:1 with screen pixels (except when the transform--or any of its parent transforms--are scaled, or if the canvas itself is in Worldspace (in which case you kinda have to guess)).

第三位在文本对象的Transform上:您可以另外 scale 对象,并获得(视在)字体大小以进行更改,尽管放大将使其看起来模糊,而缩小则将使它看起来很混叠.无论哪种方式,它看起来都不好.

The third place is on the text object's Transform: you can additionally scale the object and get the (apparent) font size to change although scaling it up will make it look blurry and scaling it down will make it look aliased. Either way it looks bad.

所有这些,我发现最好的结果是加倍字体大小并将转换比例减小到0.5,因为默认比例下的文本抗锯齿对我来说很模糊,因此使用更大的字体和比例向下变换的对象将其锐化.您仍然需要自己进行测试.

All that said, I've found best results to be to double the font size and reduce the transform scale to 0.5 as the text anti-aliasing at the default scale looks blurry to me, so using a bigger font size and scaling the object transform back down sharpens it up. You'll still want to test for yourself if it needs it.

这篇关于实际上,fontSize在Unity中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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