Created
April 9, 2020 16:04
-
-
Save smkplus/ee419d48cf5e6848a41c732a3fd63829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using UnityEngine.UI; | |
| public class UIComponent : MonoBehaviour | |
| { | |
| [SerializeField] private Text scoreText; | |
| [SerializeField] private Text lifeText; | |
| [SerializeField] private Image gameOverOverlay; | |
| private void Start() | |
| { | |
| InitializeUI(); | |
| } | |
| private void InitializeUI() | |
| { | |
| gameOverOverlay.gameObject.SetActive(false); | |
| if (scoreText != null) | |
| { | |
| scoreText.text = GameConstants.SCORE_TXT + "0"; | |
| scoreText.gameObject.SetActive(true); | |
| } | |
| if (lifeText != null) | |
| { | |
| lifeText.text = GameConstants.LIFE_TXT + GameConstants.INITIAL_LIFE.ToString(); | |
| lifeText.gameObject.SetActive(true); | |
| } | |
| } | |
| public void DisableTextUI() | |
| { | |
| if (scoreText != null) | |
| { | |
| scoreText.gameObject.SetActive(false); | |
| } | |
| if (lifeText != null) | |
| { | |
| lifeText.gameObject.SetActive(false); | |
| } | |
| } | |
| public void UpdateScore(int score) | |
| { | |
| if (scoreText != null) | |
| { | |
| scoreText.text = GameConstants.SCORE_TXT + score.ToString(); | |
| } | |
| } | |
| public void UpdateLife(int life) | |
| { | |
| if (lifeText != null) | |
| { | |
| lifeText.text = GameConstants.LIFE_TXT + life.ToString(); | |
| } | |
| } | |
| public void ShowGameOverOverlay() | |
| { | |
| gameOverOverlay.gameObject.SetActive(true); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment