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();
}
}
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » unity 分秒毫秒显示
发表评论 取消回复