I tried displaying score but I am getting NullRefrenceException error in level 2 while trying to display the score. But working fine in level 1.
Level 1:-
Level 2:-
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class GameStatus : MonoBehaviour {
[Range(0.1f,10f)] [SerializeField] float GameSpeed = 1f;
[SerializeField] int PointsPerBlockDestroyed = 10;
[SerializeField] int CurrentScore=0;
[SerializeField] TextMeshProUGUI scoreText;
private void Start()
{
}
// Update is called once per frame
void Update () {
Time.timeScale = GameSpeed;
}
public void AddToScore()
{
CurrentScore += PointsPerBlockDestroyed;
scoreText.text = "" + CurrentScore.ToString();
}
}
Also, blocks are not getting destroyed in level 2. But when I remove scoreText.text = “” + CurrentScore.ToString(); in method public void AddToScore().