As soon as I added music file to ball object , the bricks are not being destroyed. Help me in this regard
using UnityEngine;
using System.Collections;
public class Brick : MonoBehaviour {
public Sprite[] hitsprites;
public static int breakablecount=0;
bool IsBreakable;
private int timeshit;
private LevelManager levelManager;
// Use this for initialization
void Start () {
IsBreakable = (this.tag== "Breakable");
if (IsBreakable) {
print(breakablecount);
breakablecount++;
}
timeshit = 0;
levelManager=GameObject.FindObjectOfType<LevelManager>();
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D collision){
if (IsBreakable) {
handlehits ();
}
}
void handlehits(){
int maxHits = hitsprites.Length + 1;
if (timeshit >= maxHits) {
breakablecount--;
levelManager.BrickDestroyed();
print(breakablecount);
Destroy (gameObject);
} else {
LoadSprites();
}
}
void LoadSprites(){
int spriteindex = timeshit - 1;
if (hitsprites [spriteindex]) {
this.GetComponent<SpriteRenderer> ().sprite = hitsprites [spriteindex];
}
}
void Simulatewin (){
levelManager.LoadNextLevel ();
}
}
and I have added an image from console.