编辑:解决。用TextMeshProUGUI 代替 TextMeshPro**.**
背景:
我使用TextMeshPro来显示文本。我想通过脚本修改文本。问题是,当我试图更改它时,我会得到一个NullReferenceException。
详细信息:
我的剧本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class UI_speed : MonoBehaviour {
TextMeshPro textmeshPro;
void Start () {
textmeshPro = GetComponent<TextMeshPro>();
textmeshPro.text = "test";
}
}代码与TextMeshPro API匹配,所以我不确定发生了什么。我用的是团结5.6.1f1。任何帮助都是非常感谢的。谢谢。

发布于 2017-12-11 23:38:37
找到了解决办法。使用TextMeshProUGUI而不是TextMeshPro。不确定细节,但效果很好。
发布于 2017-12-11 21:45:39
试着使用
textmeshPro = GetComponentInChildren<TextMeshPro>();https://stackoverflow.com/questions/47761666
复制相似问题