I got an error upon answering all the quiz it only pop-up upon showing the end screen on line
WinScreen.ShowfinalScore () (at Assets/Scripts/WinScreen.cs:24)
GameManager.Update () (at Assets/Scripts/GameManager.cs:28)
WinScreen.cs
{
[SerializeField] TextMeshProUGUI finalScoreText;
ScoreKeeper scoreKeeper;
// Start is called before the first frame update
void Start()
{
scoreKeeper = FindObjectOfType<ScoreKeeper>();
}
// Update is called once per frame
void Update()
{
}
public void ShowfinalScore()
{
finalScoreText.text = "Congratulations!\n You got a score of " + scoreKeeper.CalculateScore() + "%"; // this is the line 24
}
}
Gamemanager.cs
Quiz quiz;
WinScreen winScreen;
// Start is called before the first frame update
void Start()
{
quiz = FindObjectOfType<Quiz>();
winScreen = FindObjectOfType<WinScreen>();
quiz.gameObject.SetActive(true);
winScreen.gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (quiz.isComplete)
{
quiz.gameObject.SetActive(false);
winScreen.gameObject.SetActive(true);
winScreen.ShowfinalScore(); // line 28
}
}
public void OnReplayLevel()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}