Day 23 — Getting started with the UI system

using UnityEngine.UI;[SerializeField]
private Text _scoreText;
public void UpdateScore(int playerScore)
{
_scoreText.text = "Score: " + playerScore;
}
_player = GameObject.Find("Player").GetComponent<Player>();
if (_player != null)
{
_player.AddScore(Random.Range(5, 20));
}
private int _score;
private UIManager _uiManager;
public void AddScore(int points)
{
_score += points;
_uiManager.UpdateScore(_score);
}
_uiManager = GameObject.Find("UIManager").GetComponent<UIManager>();

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store