如何讓標籤中字體的大小更大?如何在Unity中設置文本的字體大小?
我用這個功能來顯示文本:
function OnGUI()
{
GUI.color = Color.green;
GUI.Label(Rect(500,350,200,50),"Lose");
}
這導致:
我怎樣才能讓這個文字變大?
如何讓標籤中字體的大小更大?如何在Unity中設置文本的字體大小?
我用這個功能來顯示文本:
function OnGUI()
{
GUI.color = Color.green;
GUI.Label(Rect(500,350,200,50),"Lose");
}
這導致:
我怎樣才能讓這個文字變大?
Unity的GUI現在支持 「豐富的文本」 標籤。
http://docs.unity3d.com/Documentation/Manual/StyledText.html
所以這會工作:
GUI.Label(Rect(500,350,200,50),"<color=green><size=40>Lose</size></color>");
只需創建一個合適的GUIStyle
並設置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);
}
}
將導致
哈,這表明我沒有使用Unity的GUI的東西,除了編輯器擴展。 :) 感謝那。 +1 – Bart
@Bart是的,它很方便,但除了編輯器擴展和FPS計數器之外,我還不會使用即時模式GUI。 – Calvin
謝謝:)))有用。 – Akari