WasCancelled()
Checks whether the work represented by this progress state was cancelled.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEngine.LightTransport
- Assembly: UnityEngine.CoreModule
public bool WasCancelled()
Returns
Type | Description |
|---|---|
| bool | True if the work was cancelled. |
Remarks
Returns true if BakeProgressState.Cancel was called on this progress state. This method can be used by both the implementation and user code to check if cancellation was requested.
Usage Patterns:
- Check cancellation status after operations complete.
- Poll during long-running custom operations.
- Determine final operation result (success vs cancelled).
Note: A cancelled operation may still produce partial results depending on when cancellation occurred.
Examples
// Handle cancellation in batch processingusing var progress = new BakeProgressState();progress.SetTotalWorkSteps((ulong)scenes.Length);var results = new List<BakeResult>();for (int i = 0; i < scenes.Length; i++){ // Check for cancellation before each scene if (progress.WasCancelled()) { Debug.Log($"Batch cancelled after {i} scenes"); break; } var sceneResult = BakeScene(scenes[i], progress); results.Add(sceneResult); progress.IncrementCompletedWorkSteps(1);}// Determine final statusif (progress.WasCancelled()){ Debug.Log($"Batch processing cancelled. Completed {results.Count}/{scenes.Length} scenes.");}else{ Debug.Log($"Batch processing completed successfully. Processed {results.Count} scenes.");}