当前位置:网站首页>【Unity技术积累】简易计时器 & 协程 & 延时函数
【Unity技术积累】简易计时器 & 协程 & 延时函数
2022-07-17 11:57:00 【FYK0q0】
使用协程实现简易计时器
public class Timer_Coroutine : MonoBehaviour
{
void Start()
{
StartCoroutine(Timer());
}
int time = 0;
IEnumerator Timer()
{
while (true)
{
time++;
yield return new WaitForSeconds(1);
print(time);
}
}
}

使用延时函数实现计时器
public class Timer_Delayed : MonoBehaviour
{
int time = 0;
void Start()
{
InvokeRepeating("Timer", 1, 1);
}
private void Timer()
{
time++;
print(time);
}
}

边栏推荐
- Good news
- Flink入门到实战-阶段五(处理函数)
- 华为Ascend910运行yolov3教程
- TP5 judgment request mode
- 6G空天地一体化网络高空平台基站下行频谱效率研究
- 氟改性UiO-66|3,4-二羟基苯甲醛改性UiO-66-NH2|喜树碱衍生物/寡肽@ZIF-8纳米载药体系
- Code to celebrate the Dragon Boat Festival -- Zong your heart
- 2022年湖南省中职组“网络空间安全”赛题解析(超详细)
- [Download] take you to use FRP to achieve intranet penetration detailed tutorial!
- Cmake -- Notes
猜你喜欢
![[200 opencv routines] 233 Moment invariants of regional features](/img/03/8d4bd81a839f18142e7ee14adbfa40.png)
[200 opencv routines] 233 Moment invariants of regional features

Packet knowledge

Go to school = earn money? Immortal college without paying tuition fees!

Data Lake (XII): integration of spark3.1.2 and iceberg0.12.1

Network Security Learning (Qianfeng network security notes) 1-- building virtual machines

荔枝音质高保真AI降噪技术分享

数据包知识

The module created by yourself uses CMD to open the report modulenotfounderror: no module named solution

5分钟就能轻松入门的机器学习基础知识

Online education knowledge payment website source code system + live broadcast + applet, installation tutorial
随机推荐
Huawei wireless device configuration dynamic load balancing
set、vector与list的构造与排序的耗时测试
Blender数字孪生制作教程
[C language] shallow selection, circular statements, functions and arrays
ROV and AUV of underwater vehicle
【C语言】浅涉选择、循环语句、函数及数组
在线教育知识付费网站源码系统+直播+小程序,安装教程
ty_ Gr551x code framework
一种基于Grubbs和孤立森林的多维序列异常检测方法
Clwy permission management (III) -- user group module
Clwy permission management (I) -- project construction
完全背包问题代码模板
Story of status code
【东北师范大学】考研初试复试资料分享
Clwy authority management (II) -- user module
A multidimensional sequence anomaly detection method based on Grubbs and isolated forest
Run yolov3 on Huawei modelarts_ coco_ detection_ dynamic_ AIPP sample
2022年湖南 省中职组“网络空间安全”Windows渗透测试 (超详细)
Rocky基础之正则表达式
QT学习日记17——Qt数据库