Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using TMPro;
- using UnityEngine;
- public class ScoreController : MonoBehaviour
- {
- [SerializeField] private TextMeshProUGUI scoreText;
- public int Score { get; private set; }
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.D))
- {
- UpdateScore(2);
- }
- if (Input.GetKey(KeyCode.A))
- {
- UpdateScore(1);
- }
- }
- public void UpdateScore(int value)
- {
- Score += value;
- scoreText.text = $"{Score}";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment