public void GenerateAsync() { UpdateControlPoints(); int pointsToGenerate = CatmullRomSpline.CalculateGeneratedPointsToGenerate(controlPoints.Count, closedLoop, resolution); List <CatmullRomSplinePoint> initialResults = new List <CatmullRomSplinePoint>(pointsToGenerate); IEnumerable <CatmullRomSplinePoint> sequence = CatmullRomSpline.GenerateSplinePointsSequence(controlPoints, closedLoop, resolution); var timeBudgettedCoroutine = CoroutineUtils.FrameTimeBudgettedCoroutine(initialResults, sequence, ProcessSingleResult, ProcessAccumulatedResults, ProcessResults, frameTimeBudget); if (asyncGenerateCoroutine != null) { StopCoroutine(asyncGenerateCoroutine); asyncGenerateCoroutine = null; } asyncGenerateCoroutine = StartCoroutine(timeBudgettedCoroutine); }