//clean trash if full and clicked on private void OnMouseDown() { if (this.isFull()) { fullitude = 0; if (this.gameObject.tag == "Yellow") { progress.GetComponent <ProgressManager>().UpdateScore(maxCapacity); board.compostCounter = 0; for (int i = 0; i < board.toRecycle.Length; i++) { if (board.toRecycle[i]) { board.toRecycle[i].GetComponent <Dot>().Recycle(); //Destroy(board.toCompost[i]); board.toRecycle[i] = null; } } } else if (this.gameObject.tag == "Brown") { progress.GetComponent <ProgressManager>().UpdateScore(maxCapacity); board.compostCounter = 0; for (int i = 0; i < board.toCompost.Length; i++) { if (board.toCompost[i]) { board.toCompost[i].GetComponent <Dot>().Recycle(); //Destroy(board.toCompost[i]); board.toCompost[i] = null; } } } else if (this.gameObject.tag == "White") { progress.GetComponent <ProgressManager>().UpdateScore(maxCapacity); board.glassCounter = 0; for (int i = 0; i < board.toGlass.Length; i++) { if (board.toGlass[i]) { board.toGlass[i].GetComponent <Dot>().Recycle(); //Destroy(board.toCompost[i]); board.toGlass[i] = null; } } } else if (this.gameObject.tag == "Blue") { progress.GetComponent <ProgressManager>().UpdateScore(maxCapacity); board.electronicCounter = 0; for (int i = 0; i < board.toElectronic.Length; i++) { if (board.toElectronic[i]) { board.toElectronic[i].GetComponent <Dot>().Recycle(); //Destroy(board.toCompost[i]); board.toElectronic[i] = null; } } } //empty can Debug.Log(fullitude); } }