arenos-nexus/Arenos Nexus/Library/PackageCache/com.unity.collab-proxy@ab839cc7d2ad/Editor/UVCSToolbar/Headless/HeadlessUpdateProgress.cs
Daniel 2e704cae70 init
Init Commit Unity
2025-09-25 22:01:28 +02:00

60 lines
1.6 KiB
C#

using System;
using UnityEditor;
using Codice.Client.BaseCommands;
using Codice.Client.Commands;
using PlasticGui.WorkspaceWindow;
using PlasticGui.WorkspaceWindow.Update;
namespace Unity.PlasticSCM.Editor.Toolbar.Headless
{
internal class HeadlessUpdateProgress
{
internal void ShowUpdateProgress(string title, UpdateNotifier notifier)
{
mProgressData = new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);
if (mProgressId == -1)
Progress.Finish(mProgressId);
mProgressId = Progress.Start(title);
mUpdateProgressNotifier = notifier;
EditorApplication.update += UpdateProgress;
}
internal void EndUpdateProgress()
{
EditorApplication.update -= UpdateProgress;
Progress.Finish(mProgressId);
mProgressId = -1;
}
internal bool IsOperationRunning()
{
return mProgressId != -1;
}
void UpdateProgress()
{
if (mProgressId == -1)
return;
UpdateOperationStatus status = mUpdateProgressNotifier.GetUpdateStatus();
float progress = GetProgressBarPercent.ForTransfer(
status.UpdatedSize, status.TotalSize) / 100f;
Progress.Report(
mProgressId,
progress,
UpdateProgressRender.GetProgressString(status, mProgressData));
}
int mProgressId = -1;
UpdateNotifier mUpdateProgressNotifier;
BuildProgressSpeedAndRemainingTime.ProgressData mProgressData;
}
}