기술 자료

Unity Engine

Unity Engine

Cancel()

Cancel the asynchronous operation.
읽는 시간 1분최근 업데이트: 한 달 전

Definition

public void Cancel()

Remarks

Requests cancellation of any ongoing operations that use this progress state. This method returns immediately and the operation is cancelled once the implementation has a chance to react to the request and terminate the operation.
Cancellation Behavior:
  • The cancellation request is cooperative - operations must check for cancellation.
  • Not all operations support cancellation.
  • Cancellation may take time to take effect.
  • Use BakeProgressState.WasCancelled to check if cancellation was requested.
Note: This method only requests cancellation; it does not force immediate termination.

Examples

// Set up cancellable baking operationusing var progress = new BakeProgressState();var integrator = new RadeonRaysProbeIntegrator();integrator.SetProgressReporter(progress);// Start long-running operationvar bakeTask = Task.Run(() =>{ return integrator.IntegrateIndirectRadiance( context, 0, 10000, 4096, false, outputBuffer);});// Allow user to cancel with UI buttoncancelButton.onClick.AddListener(() =>{ progress.Cancel(); statusText.text = "Cancelling...";});// Wait for completion or cancellationvar result = await bakeTask;if (progress.WasCancelled()){ statusText.text = "Bake was cancelled";}