在網(wǎng)上找了很多都沒有涉及到這個(gè)TextMeshPro內(nèi)容修改,踩了很多坑,記錄一下
特別是using TMPro; public TextMeshProUGUI Text; GetComponent();
1、在Unity3D中創(chuàng)建一個(gè)TextMeshPro
文章來源:http://www.zghlxwxcb.cn/news/detail-503345.html
2、在TextMeshPro下添加C# Script
文章來源地址http://www.zghlxwxcb.cn/news/detail-503345.html
3、打開腳本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ShowTime : MonoBehaviour
{
// Start is called before the first frame update
public TextMeshProUGUI Text;
// Start is called before the first frame update
void Start()
{
Text = transform.GetComponent<TextMeshProUGUI>();
// TxtCurrentTime = GetComponent<TextMeshPro> ();
}
// Update is called once per frame
void Update()
{
//獲取系統(tǒng)當(dāng)前時(shí)間
System.DateTime NowTime = System.DateTime.Now.ToLocalTime();
Text.text = NowTime.ToString("HH:mm");
}
}
到了這里,關(guān)于Unity3D使用C#腳本修改TextMeshPro的內(nèi)容(以顯示系統(tǒng)時(shí)間為例)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!