Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


BakeProgressState

Provides progress reporting and cancellation support for asynchronous light baking operations.
Read time 1 minuteLast updated 7 days ago

Definition

public class BakeProgressState : IDisposable

Remarks

This class reports progress for ongoing asynchronous bake operations and provides a method to request the cancellation of the operation. It supports work-step based progress tracking and can be shared across multiple operations for unified progress reporting.
BakeProgressState is commonly used with:
  • PopulateWorld for world population progress.
  • IProbeIntegrator methods for integration progress tracking.
  • Long-running light transport operations that benefit from progress feedback.
The progress state uses a work-step model where the total expected work is set upfront and completed work is incremented as operations progress.

Examples

// Set up progress tracking for a baking operationusing var progress = new BakeProgressState();progress.SetTotalWorkSteps(1000);// Configure integrator to report progressvar integrator = new RadeonRaysProbeIntegrator();integrator.SetProgressReporter(progress);// Start integration operationvar integrationTask = Task.Run(() =>{ return integrator.IntegrateDirectRadiance( context, 0, probeCount, 2048, false, outputBuffer);});// Monitor progress and allow cancellationwhile (!integrationTask.IsCompleted){ float currentProgress = progress.Progress(); Debug.Log($"Baking progress: {currentProgress * 100:F1}%"); // Check for user cancellation if (Input.GetKeyDown(KeyCode.Escape)) { progress.Cancel(); Debug.Log("Cancelling bake operation..."); } await Task.Delay(100);}// Check if operation was cancelledif (progress.WasCancelled()){ Debug.Log("Bake operation was cancelled");}else{ var result = await integrationTask; Debug.Log($"Bake completed: {result.type}");}

Constructors

Constructor

Description

BakeProgressState()Constructor.

Methods

Method

Description

CancelCancel the asynchronous operation.
DisposeDispose the BakeProgressState object.
IncrementCompletedWorkStepsIncrements the amount of completed work steps for this progress state.
ProgressGet the progress value.
SetTotalWorkStepsSets the total amount of work steps for the progress state. Increase the completed work steps using BakeProgressState.IncrementCompletedWorkSteps.
WasCancelledChecks whether the work represented by this progress state was cancelled.