Files
RunRunRunP/Assets/Code/UI/RestartPanel.cs
T
2026-05-04 12:45:12 +03:00

36 lines
798 B
C#

using System;
using Code.GameplayServices;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Code.UI
{
public class RestartPanel : MonoBehaviour
{
[SerializeField] private Button restartButton;
[SerializeField] private TMP_Text scoreText;
private void Awake()
{
restartButton.onClick.AddListener(RestartGame);
}
private void OnDestroy()
{
restartButton.onClick.RemoveListener(RestartGame);
}
private void OnEnable()
{
ShowScore();
}
private void ShowScore()
{
scoreText.text = PlayerScoreService.Instance.Score.ToString();
}
private void RestartGame() => GameplayManager.Instance.RestartGame();
}
}