I was getting the same Null reference exception that others were having.
Tried restarting Unity. Double checked the hierarchy but none of it worked.
For me the solution was to use TMP_Text instead of TextMeshPro. I recall we used TMP_Text earlier in the course.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using System;
[ExecuteAlways]
public class CoordinateLabeler : MonoBehaviour
{
TMP_Text label;
private void Awake()
{
label = GetComponent<TMP_Text>();
}
private void Update()
{
// Editor mode only
if (!Application.isPlaying)
{
UpdateLabel();
}
}
private void UpdateLabel()
{
label.text = "x,y";
}
}