当前位置:网站首页>[unity technology accumulation] simple timer & Co process & delay function
[unity technology accumulation] simple timer & Co process & delay function
2022-07-19 11:40:00 【FYK0q0】
Use the co process to realize a simple timer
public class Timer_Coroutine : MonoBehaviour
{
void Start()
{
StartCoroutine(Timer());
}
int time = 0;
IEnumerator Timer()
{
while (true)
{
time++;
yield return new WaitForSeconds(1);
print(time);
}
}
}

Implement timer with delay function
public class Timer_Delayed : MonoBehaviour
{
int time = 0;
void Start()
{
InvokeRepeating("Timer", 1, 1);
}
private void Timer()
{
time++;
print(time);
}
}

边栏推荐
猜你喜欢

Docker install MySQL

To build agile teams, these methods are indispensable

【多线程】JUC详解 (Callable接口、RenntrantLock、Semaphore、CountDownLatch) 、线程安全集合类面试题

Wechat applet cloud development 1 - Database

Unity高版本退回低版本报错问题

MySQL autoincrement ID, UUID and snowflake ID

Developing those things: how to solve the problem of long-time encoding and decoding of RK chip video processing?

Synchronized lock upgrade

Un modèle de détection par défaut basé sur le réseau neuronal évolutif rapide dans le contrôle de la qualité des produits - lire les notes

常见分布式锁介绍
随机推荐
What do you look at after climbing the wall? The most popular foreign website - website navigation over the wall
TiKV 内存参数性能调优
SPI service discovery mechanism
Dream CMS foreground search SQL injection
Similarities and differences between OA system and MES system
A simple websocket example
Automated graphical interface library pyautogui
synchronized锁升级
SQL union operator
[PostgreSQL] PostgreSQL 15 optimizes distinct
565. 数组嵌套 : 常规模拟题
[untitled] CV learning 1 conversion
Configure spectrum navigation for Huawei wireless devices
机器人开发--机器人资料汇总
03-1、内联函数、auto关键字、typeid、nullptr
Robot development -- robot data summary
Leetcode 1328. 破坏回文串(可以,已解决)
Loj#2324-「清华集训 2017」小 Y 和二叉树
A curated list of awesome Qt and QML
Leetcode 1252. 奇数值单元格的数目