public static TRoutine OnProgress <TRoutine>(this TRoutine self, Action <float> handler) where TRoutine : Routine { if (self is null) { throw new NullReferenceException(nameof(self)); } if (handler is null) { throw new ArgumentNullException(nameof(handler)); } var p = new RoutineProgressHandler(self); self.AddUpdateActionInternal(() => { if (p.TryUpdateProgress(out var progress)) { handler.Invoke(progress); } }); return(self); }
public ProgressRoutine(Routine targetRoutine, Action <float> progressHandler) { _targetRoutine = targetRoutine; _routineProgress = new RoutineProgressHandler(targetRoutine); _progressHandler = progressHandler; }