I’ve ran into an issue where I keep getting the following error: “NullReferenceException: Object reference not set to an instance of an objectScoreDisplay.Update () (at assets/Scripts/ScoreDisplay.cs:23)”
I’m currently working on the “Add and Display Score” section of the Lecture and the issue appears to be related somehow to Text Mesh Pro, as I have deleted the text and recreated as just a regular text object and I have not issue the code works at is should, however using Text Mesh Pro I keep getting the same error.
Any help would be greatly appreciated!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ScoreDisplay : MonoBehaviour
{
Text scoreText;
GameSession gameSession;
// Start is called before the first frame update
void Start()
{
scoreText = GetComponent<Text>();
gameSession = FindObjectOfType<GameSession>();
}
// Update is called once per frame
void Update()
{
scoreText.text = gameSession.GetScore().ToString();
}
}