Version: Unity 6.3 LTS (6000.3)
LanguageEnglish
  • C#

BakeProgressState.WasCancelled

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool WasCancelled();

Returns

bool True if the work was cancelled.

Description

Checks whether the work represented by this progress state was cancelled.

Returns true if 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.

// Handle cancellation in batch processing
using 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 status if (progress.WasCancelled()) { Debug.Log($"Batch processing cancelled. Completed {results.Count}/{scenes.Length} scenes."); } else { Debug.Log($"Batch processing completed successfully. Processed {results.Count} scenes."); }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961