I am trying to make a 2D brick breaker game in unity .The problems are as follows:
1) The game over text and buttons
are getting overlapped by bricks as shown in image:
2) I am getting NullReferencException
after I click on Menu
button as follows:
NullReferenceException: Object reference not set to an instance of an object
UiManager.Update () (at Assets/UiManager.cs:21)
The UiManager Script is this :
public class UiManager : MonoBehaviour {
float score=0;
public Text scoreText;
public Text endText;
public Button[] buttons;
public Text TIMER;
float time=30f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
time -=Time.deltaTime;
TIMER.text = "TIME: " + (int)time;
if (time < 1) {
GameOverF ();
Time.timeScale = 0;
}
}
public void IncrementScore(){
score++;
scoreText.text = "SCORE: " + score;
}
public void IncrementBadScore(){
score-=11;
scoreText.text = "SCORE: " + score;
}
public void IncrementGoodScore(){
score+=11;
scoreText.text = "SCORE: " + score;
}
public void IncrementRedScore(){
score-=2;
scoreText.text = "SCORE: " + score;
}
public void GameOverF(){
endText.gameObject.SetActive (true);
foreach (Button button in buttons) {
button.gameObject.SetActive (true);
}
}
public void exit(){
Application.Quit ();
}
public void Play(){
Application.LoadLevel ("level1");
}
public void Menu(){
Application.LoadLevel ("menu");
}
}
This error is causing my game to hang after I click on Play next time so I have to restart the game only !
line of code is this :
Now how to remove these errors ? I am not able to figure out please help !