So… I check my code and didn’t find what’s the problem. The score isn’t work, VisualStudio don’t point any error in the code but when I start the game, Unity show me this message:
And the score isn’t updating or even showing. I check if I forgot to do something in Unnity but nothing that I can see, at least.
Here’s the code, equals to Gary’s code (I check the lecture’s project changes)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class UIDisplay : MonoBehaviour
{
[Header(“Health”)]
[SerializeField] Slider healthSlider;
[SerializeField] Health playerHealth;
[Header("Score")]
[SerializeField] TextMeshProUGUI scoreText;
ScoreKeeper scoreKeeper;
void Awake()
{
scoreKeeper = FindObjectOfType<ScoreKeeper>();
}
void Start()
{
healthSlider.maxValue = playerHealth.GetHelth();
}
void Update()
{
healthSlider.value = playerHealth.GetHelth();
scoreText.text = scoreKeeper.GetScore().ToString("0000000");
}
}