private void CompleteAnalysis()
        {
            analysisTime.Stop();
            analysis.Analyze();

            UnityUtil.Destroy(generator.Root);
            OnAnalysisComplete();
        }
        private void Update()
        {
            if (targetIterations <= 0)
            {
                return;
            }

            Stopwatch sw = Stopwatch.StartNew();

            int iterationsThisFrame = 0;
            int remainingIterations = targetIterations - currentIterations;

            for (int i = 0; i < remainingIterations; i++)
            {
                if (sw.Elapsed.TotalSeconds >= PerFrameAnalysisTime)
                {
                    break;
                }

                if (generator.Generate())
                {
                    analysis.IncrementSuccessCount();
                    analysis.Add(generator.GenerationStats);
                }

                currentIterations++;
                iterationsThisFrame++;
            }

            analysisTime += sw.Elapsed.TotalSeconds;

            if (MaximumAnalysisTime > 0 && analysisTime >= MaximumAnalysisTime)
            {
                targetIterations = currentIterations;
                finishedEarly    = true;
            }

            if (currentIterations >= targetIterations)
            {
                targetIterations = 0;
                analysis.Analyze();

                UnityUtil.Destroy(generator.Root);
                OnAnalysisComplete();
            }
        }