public void Start() { if (!GetTimers.ContainsKey(this.UniqueName)) { GetTimers.Add(this.UniqueName, this); } _fCreationTime = (float)Time.time; _fNextIteration = _fCreationTime + Delay; }
public static void Clear() { foreach (util_timer timer in GetTimers.Values.ToList()) { if (timer != null) { timer.Stop(); } } GetTimers.Clear(); }
public static util_timer Create(int reps, float delay, Action func, string uniqueName = "") { if (String.IsNullOrEmpty(uniqueName)) { uniqueName = MxTimer.ToString(); MxTimer++; } var t = new util_timer { Iterations = reps, Delay = delay, Func = func, UniqueName = uniqueName }; // Check if timer already exists if (GetTimers.ContainsKey(uniqueName)) if (GetTimers[uniqueName] != null) t = GetTimers[uniqueName]; t.Start(); return t; }
public void Stop() { if (GetTimers.ContainsKey(this.UniqueName)) GetTimers.Remove(this.UniqueName); }