当前位置:网站首页>untiy countdown
untiy countdown
2022-08-09 06:01:00 【Wu Zimu】
实现例如 01:30:50的倒计时
/// <summary>
/// countdown text box
/// </summary>
private Text countDownText;
/// <summary>
/// 剩余的秒数
/// </summary>
private int secondsRemainng = 0;
private void OnDestroy()
{
//停止协程
StopAllCoroutines();
}
/// <summary>
/// 设置倒计时
/// </summary>
public void SetCountDown(int totalTime)
{
if (countDownText == null)
{
countDownText = transform.Find("TopPanel/CountDownText").GetComponent<Text>();
}
secondsRemainng = totalTime;
StartCoroutine(SetCountDownIE());
}
/// <summary>
/// Set the countdown coroutine
/// </summary>
private IEnumerator SetCountDownIE()
{
while (secondsRemainng > 0)
{
yield return new WaitForSeconds(1f);
secondsRemainng--;
//计算剩余时间
int hour, minute, second;
hour = secondsRemainng / 3600;
minute = (secondsRemainng % 3600)/60;
second = (secondsRemainng % 3600 % 60);
countDownText.text = hour.ToString("d2") + ":" + minute.ToString("d2") + ":" + second.ToString("d2");
}
//倒计时结束,结束考试
ExamControllerBase.Instance.FinishExam();
}
The method is called when usedSetCountDown();
例如
SetCountDown(3670);
边栏推荐
- deploy上传到私服配置注意事项(踩坑经验)
- 【Word】Word 正文中同时加上下标
- Unity 五子棋游戏设计和简单AI(2)
- S7-200SMART PLC Modbus TCP通信
- GNNExplainer应用于节点分类任务
- command,shell,raw,script模块的作用和区别,file、copy、fetch、synchronize的应用
- Cysteine/Galactose/Perylenediimide Functionalized Fe3O4 Fe3O4 Nanomaterials | Scientific Research Reagents
- 弄潮 Web3 欧易OKX全球「抢人」
- JVM:(六)运行时数据区之本地方法栈
- 一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
猜你喜欢
sql问题解答创建表的语句
Chapter 3 Search and Graph Theory (1)
SiO2/KH550修饰四氧化三铁纳米磁性颗粒|PDA包裹四氧化三铁磁性纳米颗粒(科研级)
Getting started with kubernetes apparmor
一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
A day to learn a public company: Sophia
MySQL LIMIT + order by limit n,m 和 limit n的小坑
JMeter test - JMeter 】 【 upload multiple images/batch CSV file upload pictures interface parametric method
The request was rejected because the URL contained a potentially malicious String “//“
第三章搜索与图论(一)
随机推荐
LDO和DC-DC的区别
Molybdenum disulfide/hafnium dioxide composite nanomaterials (MoS2/HfO2) | tantalum-doped hafnium dioxide nanoparticles (Qi Yue bio)
Chapter7、基于图像的光照
Xilinx Zynq ZynqMP DNA
MYSQLg advanced ------ batch insert millions of data
地理空间分析库turf.js的学习
Unity五子棋游戏设计 和简单AI实现(1)
【R语言】交互作用 测试数据
How to pass a two-dimensional array to a function in C language?
Introduction to AIOT
S7-200SMART PLC Modbus TCP通信
分布式定时任务框架 xxl-job 源码解析
MOS管的选型
Harbor Enterprise Mirror Warehouse Construction
untiy 倒计时
bean的生命周期
弄潮 Web3 欧易OKX全球「抢人」
RT201 Domestic PA RF Power Amplifier Compatible with RFX2401C
Lock wait timeout exceeded; try restarting transaction 更新数据量范围太大,导致锁表惨案
通讯录改进即“保存”