-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLevelToDisplay.cs
More file actions
40 lines (34 loc) · 833 Bytes
/
Copy pathLevelToDisplay.cs
File metadata and controls
40 lines (34 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using RPG.Stats;
using TMPro;
using UnityEngine;
namespace RPG.UI
{
public class LevelToDisplay : MonoBehaviour
{
private BaseStats m_BaseStats;
private TextMeshProUGUI m_Text;
private void Awake()
{
m_BaseStats = GameObject.FindWithTag("Player").GetComponent<BaseStats>();
m_Text = GetComponent<TextMeshProUGUI>();
}
private void Start()
{
UpdateLevel();
}
private void OnEnable()
{
m_BaseStats.OnLevelUp += UpdateLevel;
}
private void OnDisable()
{
m_BaseStats.OnLevelUp -= UpdateLevel;
}
private bool UpdateLevel()
{
m_Text.text = $"{m_BaseStats.Level:0}";
return true;
}
}
}