?????個(gè)人主頁:@元宇宙-秩沅
????? hallo 歡迎 點(diǎn)贊?? 收藏? 留言?? 加關(guān)注?!
????? 本文由 秩沅 原創(chuàng)
????? 收錄于專欄:unity每日一記
????推薦文章?
?【軟件設(shè)計(jì)師高頻考點(diǎn)暴擊】
?【Unityc#專題篇】之c#系統(tǒng)化大禮包】
?【unity數(shù)據(jù)持久化】數(shù)據(jù)管理類_PlayerPrfs
?【unity本站最全系列】unity常用API大全一篇文章足以
??
??(A) MoveTowards 實(shí)現(xiàn)倒計(jì)時(shí)
float time;
float endTime = 10;
void Update()
{
endTime = Mathf.MoveTowards(endTime,0,Time.deltaTime*1f);
print(endTime);
}
??(B) Invoke實(shí)現(xiàn)計(jì)時(shí)器
float time;
float endTime = 10;
void Start()
{
InvokeRepeating("OTime",0,1);
}
public void OTime()
{
print(time);
time++;
}
??(C) 協(xié)程實(shí)現(xiàn)倒計(jì)時(shí)
float time = 0;
IEnumerator TimeCorutine()
{
while(true)
{
yield return new WaitForSeconds(1);
print(time++);
}
}
private void Start()
{
StartCoroutine(TimeCorutine());
}
??(D) 幀間隔直接實(shí)現(xiàn)計(jì)時(shí)器
float nowTime = 0 ;
void Update()
{
nowTime = nowTime + Time.deltaTime; //幀間隔更新時(shí)間更準(zhǔn)確
time = (int)nowTime;
print(Time);
}
????系統(tǒng)路線學(xué)習(xí)點(diǎn)擊跳轉(zhuǎn)?
?【Unityc#專題篇】之c#進(jìn)階篇】
?【Unityc#專題篇】之c#核心篇】
?【Unityc#專題篇】之c#基礎(chǔ)篇】
?【Unity-c#專題篇】之c#入門篇】
?【Unityc#專題篇】—進(jìn)階章題單實(shí)踐練習(xí)
?【Unityc#專題篇】—基礎(chǔ)章題單實(shí)踐練習(xí)
?【Unityc#專題篇】—核心章題單實(shí)踐練習(xí)
你們的點(diǎn)贊?? 收藏? 留言?? 關(guān)注?是我持續(xù)創(chuàng)作,輸出優(yōu)質(zhì)內(nèi)容的最大動力!、文章來源:http://www.zghlxwxcb.cn/news/detail-736412.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-736412.html
到了這里,關(guān)于【Unity每日一記】Unity中的計(jì)時(shí)器——4種方法的實(shí)現(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!