Reputation:
Could someone tell how could I add to a variable every second 1? Example:
Upvotes: 0
Views: 3847
Reputation: 4561
You can try coroutines out:
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);
}
}
}
Attach this script to gamobject in the scene and see in the console how the ticker logs.
Threre you could SimpNum++
Upvotes: 2