iLMS知識社群歷程檔Login
Position: 黃國哲 > Unity
1100929 TMP
by 黃國哲 2021-09-29 00:10:11, Reply(0), Views(299)

https://www.cg.com.tw/UnityTextMeshPro/


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class searchitem : MonoBehaviour
{
    public TextMeshProUGUI itemname; //提取名字為 itemname.text

    public void getnamebtn()
    {
        { GameObject.Find(itemname.text).GetComponent<ItemDisplay>().enabled = true; }
    }

    public void leavenamebtn()
    {
        { GameObject.Find(itemname.text).GetComponent<ItemDisplay>().enabled = false; }
    }
}

////////////////////////////////

using TMPro;
 
public class GameController : MonoBehaviour
{
    public TextMeshProUGUI scoreText;
    void Start ()
    {
        scoreText = GetComponent<TextMeshProUGUI>();
    }
}

Reply