I got this error every time the ball hit the bricks.
Here’s my code:
Brick.cs
using UnityEngine;
using System.Collections;
public class Brick : MonoBehaviour {
public int maxHits;
int timesHit;
private Manager levelManager;
// Use this for initialization
void Start () {
timesHit = 0;
levelManager = GameObject.FindObjectOfType<Manager>();
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D (Collision2D col) {
timesHit++;
SimulateWin();
}
// TODO Remove this method once we can actually win!
void SimulateWin() {
levelManager.LoadNextLevel();
}
}
Manager.cs
using UnityEngine;
using System.Collections;
public class Manager : MonoBehaviour {
public void LoadLevel(string name){
Debug.Log ("Level load requested for: " +name);
Application.LoadLevel (name);
}
public void Quit(){
Debug.Log ("you quit!");
UnityEditor.EditorApplication.isPlaying = false;
Application.Quit();
}
public void LoadNextLevel(){
Application.LoadLevel (Application.loadedLevel + 1);
}
}

