Unity3d C#Unity我怎么能每秒钟都做点什么?
有人能告诉我如何每秒向变量添加1吗? 例如:Unity3d C#Unity我怎么能每秒钟都做点什么?,unity3d,Unity3d,有人能告诉我如何每秒向变量添加1吗? 例如: 您可以尝试协同程序: using System.Collections; using UnityEngine; public class SecondCounter : MonoBehaviour { void Start() { StartCoroutine(logEverySecond()); } IEnumerator logEverySecond() { while (tru
您可以尝试协同程序:
using System.Collections;
using UnityEngine;
public class SecondCounter : MonoBehaviour
{
void Start()
{
StartCoroutine(logEverySecond());
}
IEnumerator logEverySecond() {
while (true) {
Debug.Log("Tick");
yield return new WaitForSeconds(1);
}
}
}
将此脚本附加到场景中的gamobject,并在控制台中查看ticker如何记录。
您可以SimpNum++
,也可以使用计时器或简单地使用计时器,例如。。。网上有很多例子和选项。。。