Как решить проблему с TMPro?

При нажатии на "G" выводит такую ошибку: "Object reference not set to an instance of an object". Пытался найти имя объекта, чтобы вписать его перед каждым tmp, но не смог найти. Как решить?

using UnityEngine;
using TMPro;




public class UI : MonoBehaviour
{
    public TMP_Text tmp;
    int health = 100;
    int damage = 20;
    int newhealth;
    // Start is called before the first frame update
    void Start()
    {
        //TMP_Text tmp = new TMP_Text();

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.G))
        {
            newhealth = health - damage;

            if (newhealth >= 50)
            {
                tmp.text = "Health: good";
            }
            if (newhealth <= 50)
            {
                tmp.text = "Health: bad";
            }
        }
    }
}

Ответы (1 шт):

Автор решения: mendzek

Решил проблему использованием tmp.SetText() вместо tmp.text. Если есть решение проще -- я готов посмотреть.

→ Ссылка