summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/HistoryProgressSpinner.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/HistoryProgressSpinner.cs')
-rw-r--r--Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/HistoryProgressSpinner.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/HistoryProgressSpinner.cs b/Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/HistoryProgressSpinner.cs
new file mode 100644
index 0000000..fad3b82
--- /dev/null
+++ b/Library/PackageCache/com.unity.collab-proxy@1.2.16/Editor/Collab/Views/HistoryProgressSpinner.cs
@@ -0,0 +1,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();
+ }
+ }
+}