using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Num : MonoBehaviour
{
private int score;
public TextMeshPro TMP;
void Start()
{
TMP = GetComponent<TextMeshPro>();
score = 0;
}
void Update()
{
TMP.text = score.ToString();
score++;
}
}文本没有改变,我不知道为什么。控制台中的错误是"NullReferenceException: Object reference not set to an object Num.Update () (at Assets/Scripts/Num.cs:19)“。
发布于 2019-05-13 10:46:46
错误在于您的脚本没有找到TextMeshPro同级组件。如果您使用的是UI版本,那么您实际需要的是找到一个TextMeshProUGUI
发布于 2019-05-13 20:17:55
我猜这是你说的文字界面。如果是文本UI和Textmeshpro,则使用TMPro.TextMeshProUGUI varName;
https://stackoverflow.com/questions/56105003
复制相似问题