using System.Collections; using System.Collections.Generic; using UnityEngine; using Assets.Scripts.CharacterScripts; using TMPro; public class LevelTextController : MonoBehaviour { private TextMeshProUGUI levelText; // The text for the level UI public PlayerController player; // The player public PauseMenuController pauseMenu; // Reference to the pause menu // Start is called before the first frame update void Start(){ // Get the text levelText = GetComponent(); // Update it if necessary UpdateText(); player = GameObject.FindGameObjectWithTag("Player").GetComponent(); } // Update is called once per frame void Update(){ // If the player just leveled up, update the text and update the levelUp variable if (player.levelUp){ // Update the stats in the pause menu pauseMenu.UpdateStats(); UpdateText(); player.levelUp = false; } } void UpdateText(){ // Set the text to the new level levelText.text = "Level " + player.playerLevel; } }