gpt4 book ai didi

unity-game-engine - Unity中如何设置文本的字体大小?

转载 作者:行者123 更新时间:2023-12-02 20:44:03 24 4
gpt4 key购买 nike

如何使标签中的字体变大?

我用这个函数来显示文本:

function OnGUI()
{
GUI.color = Color.green;
GUI.Label(Rect(500,350,200,50),"Lose");
}

结果是:

如何使该文本变大?

最佳答案

只需创建一个适当的 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-game-engine - Unity中如何设置文本的字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19135791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com