2020-04-18 19:02:22 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class ScorePanel : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private GameController gameController;
|
|
|
|
|
private Text text;
|
|
|
|
|
|
|
|
|
|
private void Awake() {
|
|
|
|
|
gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();
|
2020-04-18 22:45:36 +02:00
|
|
|
|
text = GetComponentInChildren<Text>();
|
2020-04-18 19:02:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Start() {
|
|
|
|
|
gameController.OnScoreChange += OnScoreChange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnScoreChange(int previous, int current) {
|
|
|
|
|
text.text = current.ToString();
|
|
|
|
|
}
|
2020-04-21 01:12:21 +02:00
|
|
|
|
|
|
|
|
|
private void OnEnable() {
|
|
|
|
|
text.text = gameController.Score.ToString();
|
|
|
|
|
}
|
2020-04-18 19:02:22 +02:00
|
|
|
|
}
|