Files
drecon-unity/Assets/8_Scripts/1_Managers/UIManager.cs
2024-04-29 13:21:37 +01:00

45 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class UIManager : MonoBehaviour
{
[Header("Stat Text Objects")]
public List<TMP_Text> m_StatText;
public TMP_Text m_ModelNameText;
private void OnEnable()
{
DReConRewards.m_UpdateStat += UpdateStatText;
ModelManager.m_UpdateModelName += UpdateModelName;
}
private void OnDisable()
{
DReConRewards.m_UpdateStat -= UpdateStatText;
ModelManager.m_UpdateModelName -= UpdateModelName;
}
private void UpdateStatText(float reward, int statIndex)
{
try
{
m_StatText[statIndex].text = reward.ToString("#.000");
}
catch
{
Debug.LogError($"Text object did not exist index: {statIndex}");
}
}
private void UpdateModelName(float modelName)
{
if( m_ModelNameText != null )
{
m_ModelNameText.text = modelName.ToString("N0");
}
}
}