using UnityEditor;
namespace Unity.Pipeline.Editor
{
///
/// Drop-in replacements for 's progress-bar calls that ALSO make
/// the progress visible to a connected CLI over GET /api/progress (CLI-488).
/// EditorUtility.DisplayProgressBar has no public getter and cannot be observed from
/// the pipeline server, so existing code keeps its Editor progress dialog but stays invisible
/// to the terminal. Swapping the call site to this class keeps the exact same Editor behavior
/// and adds the CLI reporting — including while the main thread is blocked inside the task,
/// which is when the dialog (and the terminal bar) matter most:
///
/// CliEditorProgress.DisplayProgressBar("Generating World", $"Processing {i}/{n}", (float)i / n);
/// // …
/// CliEditorProgress.ClearProgressBar();
///
/// Code that can take a package dependency but runs headless (batchmode) can call
/// directly instead.
///
public static class CliEditorProgress
{
/// Same as , plus CLI reporting.
/// Short title for the operation.
/// Detail text (e.g. current step).
/// Progress in [0, 1].
public static void DisplayProgressBar(string title, string info, float progress)
{
CliProgress.Report(title, info, progress: progress);
EditorUtility.DisplayProgressBar(title, info, progress);
}
/// Same as , plus CLI reporting.
/// Short title for the operation.
/// Detail text (e.g. current step).
/// Progress in [0, 1].
/// True if the user clicked Cancel.
public static bool DisplayCancelableProgressBar(string title, string info, float progress)
{
CliProgress.Report(title, info, progress: progress);
return EditorUtility.DisplayCancelableProgressBar(title, info, progress);
}
/// Same as , plus clearing the CLI report.
public static void ClearProgressBar()
{
CliProgress.Clear();
EditorUtility.ClearProgressBar();
}
}
}