BGJ-2022.1/Assets/Scripts/UI/LevelButton.cs

22 lines
538 B
C#

using Level;
using TMPro;
using UnityEngine;
namespace UI
{
public class LevelButton : MonoBehaviour
{
private TMP_Text text = null;
public int LevelNumber { get; private set; } = 0;
private void Awake() => text = GetComponentInChildren<TMP_Text>();
public void SetLevel(string levelName)
{
text.text = levelName;
LevelNumber = System.Int32.Parse(levelName);
}
public void StartLevel() => LevelManager.Instance.SwitchToLevel(LevelNumber);
}
}