implementation of drecon in unity 2022 lts forked from: https://github.com/joanllobera/marathon-envs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0 KiB

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");
}
}
}