33 lines
749 B
C#
33 lines
749 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(TMPro.TextMeshProUGUI))]
|
|
public class UITextDisplayBase : MonoBehaviour
|
|
{
|
|
protected TMPro.TextMeshProUGUI _text;
|
|
protected ITextChangable _textChanger;
|
|
[SerializeField]
|
|
protected string _postfix;
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
_text = GetComponent<TMPro.TextMeshProUGUI>();
|
|
}
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
_textChanger.OnTextChange.AddListener(UpdateText);
|
|
}
|
|
|
|
protected virtual void OnDisable()
|
|
{
|
|
_textChanger.OnTextChange.RemoveListener(UpdateText);
|
|
}
|
|
|
|
private void UpdateText(object obj)
|
|
{
|
|
_text.SetText(obj.ToString() + _postfix);
|
|
}
|
|
}
|