For those of you using TMPRO

changes for TMP users are in script below if you dont feel like looking it up :slight_smile:

using System.Collections;
using System;
using UnityEngine;
using TMPro;

namespace RPG.UI.DamageText
{
public class DamageText : MonoBehaviour
{

    [SerializeField] TMP_Text _damageText =null;
    
 public void DestroyText()
    {
        Destroy(gameObject);
    }


    public void SetValue(float amount)
    {
        _damageText.text = String.Format("{0:0}", amount);
    }
}

}

Since we’re dealing with a UI text field here, better use

[SerializeField] TextMeshProUGUI _damageText = null;

instead.

https://docs.unity3d.com/Packages/com.unity.textmeshpro@3.0/manual/index.html

Quick Start
There are two TextMesh Pro components available. The first TMP text component is of type <TextMeshPro> and designed to work with the MeshRenderer. This component is an ideal replacement for the legacy TextMesh component.
The second TMP text component is of type <TextMeshProUGUI> and designed to work with the CanvasRenderer and Canvas system. This component is an ideal replacement for the UI.Text component.

Privacy & Terms