编辑:解决了。使用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";
}
}
Run Code Online (Sandbox Code Playgroud)
代码与TextMeshPro API匹配,所以我不确定发生了什么。我正在使用 Unity 5.6.1f1。任何帮助是极大的赞赏。谢谢你。

| 归档时间: |
|
| 查看次数: |
2434 次 |
| 最近记录: |