HistoryProgressSpinner.cs
1.87 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
69
using UnityEngine;
#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;
#else
using UnityEngine.Experimental.UIElements;
#endif
namespace UnityEditor.Collaboration
{
internal class HistoryProgressSpinner : Image
{
private readonly Texture2D[] m_StatusWheelTextures;
private bool m_ProgressEnabled;
private IVisualElementScheduledItem m_Animation;
public bool ProgressEnabled
{
set
{
if (m_ProgressEnabled == value)
return;
m_ProgressEnabled = value;
visible = value;
if (value)
{
if (m_Animation == null)
{
m_Animation = this.schedule.Execute(AnimateProgress).Every(33);
}
else
{
m_Animation.Resume();
}
}
else
{
if (m_Animation != null)
{
m_Animation.Pause();
}
}
}
}
public HistoryProgressSpinner()
{
m_StatusWheelTextures = new Texture2D[12];
for (int i = 0; i < 12; i++)
{
m_StatusWheelTextures[i] = EditorGUIUtility.LoadIcon("WaitSpin" + i.ToString("00"));
}
image = m_StatusWheelTextures[0];
style.width = m_StatusWheelTextures[0].width;
style.height = m_StatusWheelTextures[0].height;
visible = false;
}
private void AnimateProgress(TimerState obj)
{
int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f);
image = m_StatusWheelTextures[frame];
MarkDirtyRepaint();
}
}
}