【发布时间】:2021-01-26 06:43:49
【问题描述】:
好的,在 Unity 2019.4.1 中工作我有一个小故障,如果我在运行时通过脚本更改文本网格的字体,字符会出现乱码:
我在这里尝试了论坛中的解决方案:
void resetChars(TextMesh textMesh)
{
textMesh.text = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
textMesh.font.characterInfo = null;
textMesh.font.RequestCharactersInTexture(textMesh.text, textMesh.fontSize, textMesh.fontStyle);
}
if(Input.GetKey("space"))
{
resetChars(GetComponent<TextMesh>());
GetComponent<TextMesh>().font = (Font)Resources.Load("Inter-Black-slnt=0");
}
但这使情况变得更糟。这里发生了什么,如何动态更改我的 Text Mesh 字体?
【问题讨论】: