如何使标签中的字体变大?
我用这个函数来显示文本:
function OnGUI()
{
GUI.color = Color.green;
GUI.Label(Rect(500,350,200,50),"Lose");
}
结果是:
我怎样才能把这个文字变大?
只需创建一个合适的GUIStyle http://docs.unity3d.com/Documentation/Components/class-GUIStyle.html并设置fontSize
。将其传递给您的标签,然后您就可以开始了。
所以像这样:
using UnityEngine;
using System.Collections;
public class FontSizeExample : MonoBehaviour
{
GUIStyle smallFont;
GUIStyle largeFont;
void Start ()
{
smallFont = new GUIStyle();
largeFont = new GUIStyle();
smallFont.fontSize = 10;
largeFont.fontSize = 32;
}
void OnGUI()
{
GUI.Label(new Rect(100, 100, 300, 50), "SMALL HELLO WORLD", smallFont);
GUI.Label(new Rect(100, 200, 300, 50), "LARGE HELLO WORLD", largeFont);
}
}
将导致
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)