1
Fork 0
mirror of https://github.com/Steffo99/keep-everything-alive.git synced 2024-11-23 18:04:18 +00:00
keep-everything-alive/Assets/Scripts/Core/UI/ScorePanel.cs

28 lines
690 B
C#
Raw Normal View History

2020-04-18 17:02:22 +00: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 20:45:36 +00:00
text = GetComponentInChildren<Text>();
2020-04-18 17:02:22 +00:00
}
private void Start() {
gameController.OnScoreChange += OnScoreChange;
}
private void OnScoreChange(int previous, int current) {
text.text = current.ToString();
}
2020-04-20 23:12:21 +00:00
private void OnEnable() {
text.text = gameController.Score.ToString();
}
2020-04-18 17:02:22 +00:00
}