using TMPro;
using UnityEngine;

public sealed class TMP_Text_Time : MonoBehaviour
{
[SerializeField] private TMP_Text _textTime0;
[SerializeField] private TMP_Text _textTime1;
[SerializeField] private TMP_Text _textTime3;
[SerializeField] private TMP_Text _textTime4;
[SerializeField] private TMP_Text _textTime6;
[SerializeField] private TMP_Text _textTime7;

public void SetData(int minutes, int seconds, int milliseconds)
{
    SetTextValue(ref _textTime0, ref _textTime1, minutes, "0");
    SetTextValue(ref _textTime3, ref _textTime4, seconds, "0");
    SetTextValue(ref _textTime6, ref _textTime7, milliseconds, "0");
}

private void SetTextValue(ref TMP_Text txt0, ref TMP_Text txt1, int value, string defaultValue = "")
{
    txt0.text = value >= 10 ? ((int)(value * 0.1f)).ToString() : defaultValue;
    txt1.text = value >= 10 ? (value % 10).ToString() : value.ToString();
}

}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部