I need the equivalent of a .net DispatcherTimer object.
I tried this, but it does not tick. Besides using Update loop and the elapsed time, is there a more generic timer class, and how is it properly instantiated?
using UnityEngine;
using System.Collections;
using System.Timers;
public class ApplicationLaunch : MonoBehaviour {
System.Timers.Timer timer1 = new System.Timers.Timer();
// Use this for initialization
void Start ()
{
timer1 = new Timer();
timer1.Interval = 0.1;
timer1.Elapsed +=TimerTick;
timer1.Start();
}
void TimerTick(object o, System.EventArgs e)
{
Debug.Log("Tick");
}
Look into Invoke, InvokeRepeating, and coroutines.
– Eric5h5