using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.SceneManagement; public class UIManager : MonoBehaviour { public TextMeshProUGUI Health; public static UIManager instance; public CharacterController player; public GameObject GameOverPanel; public CameraFollow cameraFollow; public TextMeshProUGUI ScoreText; private void Awake() { instance = this; } private void Start() { UpdateHealth(); } public void UpdateHealth() { if (!GameManager.instance.isGameOver) { if (player.Health <= 0) { Health.text = "Health: 0"; GameOver(); } else { Health.text = "Health: " + player.Health.ToString(); } } } void GameOver() { GameManager.instance.isGameOver = true; Destroy(player.SpineHingeJoint); GameOverPanel.SetActive(true); cameraFollow.isPlaying = false; } public void Restart() { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } }