当前位置:网站首页>【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);
}
}

边栏推荐
- TP5 judgment request mode
- [fishing artifact] UI library second low code tool - form part (II) sub control
- Ffmpeg merges multiple videos (vb.net, class library-8)
- 中科磐云——网络空间安全抓包题目 B.pcap
- Flink入门到实战-阶段五(处理函数)
- Rhcsa day 1 7.11
- 荔枝音质高保真AI降噪技术分享
- Aller à l'école = gagner de l'argent? L'Académie des fées sans frais de scolarité!
- [sort] merge sort
- FFmpeg录制视频、停止(VB.net,踩坑,类库——10)
猜你喜欢

Huawei Shengsi mindspire detailed tutorial

pfSense配置Tailscal站点到站点连接

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

卫星网络中基于时变图的节能资源分配策略

QT学习日记17——Qt数据库

Flink entry to practice - stage 5 (processing function)

【微信小程序】使出千手浮图—回滚式

状态码的故事

【附下载】带你使用frp实现内网穿透详细教程!

mof定制材料|超薄MOF纳米带|磁性Fe3O4 @Cd-MOF纳米复合材料|ZIF-8/石墨烯复合纳米颗粒
随机推荐
A multidimensional sequence anomaly detection method based on Grubbs and isolated forest
华为Ascend910运行yolov3教程
Overview of 6G oriented smart reflector wireless communication
什么是pytest,自动化测试必学
JS 之 操作 String 字符串
Huawei Shengsi mindspire detailed tutorial
[sort] merge sort
潇洒郎:VMware固定虚拟机IP地址
VC view memory leak
fiddler 重放攻击,简单的模拟重放攻击
壳聚糖包裹PCN224纳米粒子|金属-有机骨架Fe-MIL-88NH2|镍基MOF材料(Ni-MOF/NF)
5分钟就能轻松入门的机器学习基础知识
Construction practice of pipeline engine of engineering efficiency ci/cd
读取二进制文件的中文乱码问题
AsyncLocalStorage 的妙用
506.相对名次
Fiddler replay attack, simple simulated replay attack
硫化铜纳米粒/ZIF-8复合材料([email protected]载体)|UiO-66/CoSO复合材料|ZIF-67纳米晶表面修饰六咪唑环三磷腈
华为无线设备配置智能漫游
FFmpeg录制视频、停止(VB.net,踩坑,类库——10)