# BakeProgressState

> Provides progress reporting and cancellation support for asynchronous light baking operations.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.LightTransport](/engine/6000.7/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
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](/engine/6000.7/script-reference/unityengine/lighttransport/iprobeintegrator.md) 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

```csharp
// Set up progress tracking for a baking operation
using var progress = new BakeProgressState();
progress.SetTotalWorkSteps(1000);

// Configure integrator to report progress
var integrator = new RadeonRaysProbeIntegrator();
integrator.SetProgressReporter(progress);

// Start integration operation
var integrationTask = Task.Run(() =>
{
    return integrator.IntegrateDirectRadiance(
        context, 0, probeCount, 2048, false, outputBuffer);
});

// Monitor progress and allow cancellation
while (!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 cancelled
if (progress.WasCancelled())
{
    Debug.Log("Bake operation was cancelled");
}
else
{
    var result = await integrationTask;
    Debug.Log($"Bake completed: {result.type}");
}
```

## Constructors

| Constructor                                                                                                 | Description  |
| ----------------------------------------------------------------------------------------------------------- | ------------ |
| [BakeProgressState()](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/ctor.md) | Constructor. |

## Methods

| Method                                                                                                                                     | Description                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Cancel](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/cancel.md)                                           | Cancel the asynchronous operation.                                                                                                                                                                                                                                |
| [Dispose](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/dispose.md)                                         | Dispose the BakeProgressState object.                                                                                                                                                                                                                             |
| [IncrementCompletedWorkSteps](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/incrementcompletedworksteps.md) | Increments the amount of completed work steps for this progress state.                                                                                                                                                                                            |
| [Progress](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/progress.md)                                       | Get the progress value.                                                                                                                                                                                                                                           |
| [SetTotalWorkSteps](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/settotalworksteps.md)                     | Sets the total amount of work steps for the progress state. Increase the completed work steps using [BakeProgressState.IncrementCompletedWorkSteps](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/incrementcompletedworksteps.md). |
| [WasCancelled](/engine/6000.7/script-reference/unityengine/lighttransport/bakeprogressstate/wascancelled.md)                               | Checks whether the work represented by this progress state was cancelled.                                                                                                                                                                                         |
