倒计时中总秒数转剩余小时、分钟、秒。
利用UniRX中的Sample操作符 实现一秒执行一次。
Observable.EveryUpdate()
.Where(_ => true)
.Sample(TimeSpan.FromSeconds(1f))
//分界线 注释:下边 “Interval"的功能就是重复延时 等同于上边三行代码
Observable.Interval(TimeSpan.FromSeconds(1f))
.Subscribe(_ =>
{
//str_time 是分钟 首先 转换为秒
// 一分钟 = 60 秒
index_SUM_seconds--;
// 小时
int index_hour = index_SUM_seconds / 3600;
// 总分钟 总小时 换成总秒数是换成总小时的秒数 换成分钟 就是换成总小时的分钟
int index_minutes = index_SUM_seconds / 60 - ((index_SUM_seconds / 3600) * 3600) / 60;
// 总秒数 总小时 换成 总小时的秒数 这个小时的分钟换成秒数
int index_seconds = index_SUM_seconds - ((index_hour * 3600) + (index_minutes * 60));
string str_Show = index_hour.ToString("00") + ":" + index_minutes.ToString("00") + ":" + index_seconds.ToString("00");
Debug.Log(str_Show);
}).AddTo(this);