How to add TMPRo for my script

i created a script that updates text when it has a trigger but the tutorial i was using uses normal text not textmeshpro and in the tutorial it said to drag the text under the text variable thing but i cant what do i do? code:

using UnityEngine;
using UnityEngine.UI;

public class Itemcollect : MonoBehaviour
{
   [SerializeField] private Text coinText;

    private int coin = 0;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Coin"))
        {
            Destroy (collision.gameObject);
            coin++;
            Debug.Log("Coin: " + coin);
            coinText.text = "coins: " + coin;
        }
    }
}

At the top: using TMPro;

Instead of “private Text coinText”, use “private TextMeshProUGUI coinText”

I use TextMeshPro myself as well

1 Like

ohh ok thanks:)

1 Like