Search Unity

Bug Text mesh pro not working

Discussion in 'UGUI & TextMesh Pro' started by FirefoxyLeGibus, Feb 5, 2023.

  1. FirefoxyLeGibus

    FirefoxyLeGibus

    Joined:
    Dec 29, 2020
    Posts:
    1
    So i'm running into this really annoying problem
    I want to show a really simple score to the screen, and i need to use TMP

    So i made a little script that just take the score as an int, and show it to the screen with scoreText.text

    The code technically work since the text update BUT it keeps saying
    NullReferenceException: Object reference not set to an instance of an object

    I really don't understand what's the problem, everything works but doesn't
    Can you help me ?
    (i'm using Unity 2021.3.17f)


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using TMPro;
    6.  
    7. public class PointManager : MonoBehaviour
    8. {
    9.     public TMP_Text scoreText;
    10.     public int score = 0;
    11.  
    12.     void Update() {
    13.         scoreText.text = score.ToString();
    14.     }
    15. }
    16.