-
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathEditorProgressView.cs
More file actions
68 lines (60 loc) · 1.95 KB
/
Copy pathEditorProgressView.cs
File metadata and controls
68 lines (60 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#if UNITY_2020_1_OR_NEWER
using UnityEditor;
namespace UnityVolumeRendering
{
public class EditorProgressView : IProgressView
{
private int progressId = -1;
private float cachedProgress;
private string cachedDescription;
public void StartProgress(string title, string description)
{
progressId = Progress.Start(title, description, Progress.Options.Sticky);
Progress.ShowDetails();
EditorApplication.update += EditorUpdate;
}
public void FinishProgress(ProgressStatus status = ProgressStatus.Succeeded)
{
if (progressId != -1)
{
Progress.Finish(progressId, status == ProgressStatus.Failed ? Progress.Status.Failed : Progress.Status.Succeeded);
progressId = -1;
}
EditorApplication.update -= EditorUpdate;
}
public void UpdateProgress(float totalProgress, float currentStageProgress, string description)
{
this.cachedProgress = totalProgress;
this.cachedDescription = description;
ShowProgress(totalProgress, description);
}
private void EditorUpdate()
{
ShowProgress(this.cachedProgress, this.cachedDescription);
}
private void ShowProgress(float progress, string description)
{
if (progressId != -1)
{
Progress.Report(progressId, progress, progress == 1.0f ? "Done" : description);
}
}
}
}
#else
namespace UnityVolumeRendering
{
public class EditorProgressView : IProgressView
{
public void StartProgress(string title, string description)
{
}
public void FinishProgress(ProgressStatus status = ProgressStatus.Succeeded)
{
}
public void UpdateProgress(float totalProgress, float currentStageProgress, string description)
{
}
}
}
#endif