private void StartCleanupActions(Queue <Action> cleanupActions) { if (cleanupActions.Count > 0) { EeRenderingProcessorUnityCycle.AddToQueue(() => Cleanup(cleanupActions)); } }
private void Cleanup(Queue <Action> cleanupActions) { try { cleanupActions.Dequeue().Invoke(); } finally { if (cleanupActions.Count > 0) { EeRenderingProcessorUnityCycle.AddToQueue(() => Cleanup(cleanupActions)); } } }
private void RunAsync(Queue <Action> actions, Queue <Action> cleanupActions) { try { actions.Dequeue().Invoke(); if (actions.Count > 0 && !StopGenerating) { EeRenderingProcessorUnityCycle.AddToQueue(() => RunAsync(actions, cleanupActions)); } else { StartCleanupActions(cleanupActions); } } catch (Exception) { StartCleanupActions(cleanupActions); } }
private void DoGenerationProcess(Camera generatedCamera) { var queue = new Queue <Action>(); for (var index = 0; index < _renderingSamples.Count; index++) { var currentPreview = _renderingSamples[index]; if (_includeTransformsMode || _renderingSamples.Count <= 1) { queue.Enqueue(() => { SampleClip(currentPreview); }); queue.Enqueue(() => { RenderToTexture(generatedCamera, currentPreview); }); } else if (index == 0) { queue.Enqueue(() => { SampleClip(currentPreview); }); } else if (index == _renderingSamples.Count - 1) { var previousPreview = _renderingSamples[index - 1]; queue.Enqueue(() => { RenderToTexture(generatedCamera, previousPreview); SampleClip(currentPreview); }); queue.Enqueue(() => { RenderToTexture(generatedCamera, currentPreview); }); } else { var previousPreview = _renderingSamples[index - 1]; queue.Enqueue(() => { RenderToTexture(generatedCamera, previousPreview); SampleClip(currentPreview); }); } } var cleanupQueue = new Queue <Action>(); cleanupQueue.Enqueue(() => Terminate(generatedCamera)); cleanupQueue.Enqueue(() => _onQueueTaskComplete.Invoke()); EeRenderingProcessorUnityCycle.AddToQueue(() => RunAsync(queue, cleanupQueue)); }