/// <summary> /// StopUpdating calling the given method periodically. Note that the method must be equal to a previously added method /// in the sense of pointer equality for it to be removed successfully. /// </summary> public void StopCallPeriodically(PeriodicMethod method) { PeriodicMethodClass toRemove = null; foreach (PeriodicMethodClass methodClass in methodsToCall) { if (methodClass.method == method) { toRemove = methodClass; } } if (toRemove != null) { methodsToCall.Remove(toRemove); } }
/// <summary> /// Add a method to be called periodically every secondsBetweenCalls seconds. /// </summary> public void StartCallPeriodically(PeriodicMethod method, float secondsBetweenCalls) { methodsToCall.Add(new PeriodicMethodClass(method, secondsBetweenCalls)); }
public PeriodicMethodClass(PeriodicMethod method, float timeBetweenCalls) { this.method = method; this.timeBetweenCalls = timeBetweenCalls; this.timeSinceLastCall = timeBetweenCalls; }