DrawProgressForDialogs.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace Unity.PlasticSCM.Editor.UI.Progress
  4. {
  5. internal static class DrawProgressForDialogs
  6. {
  7. internal static void For(ProgressControlsForDialogs.Data data)
  8. {
  9. Rect rect = GUILayoutUtility.GetRect(
  10. GUILayoutUtility.GetLastRect().width, 30);
  11. if (!string.IsNullOrEmpty(data.StatusMessage))
  12. {
  13. EditorGUI.HelpBox(rect, data.StatusMessage, data.StatusType);
  14. return;
  15. }
  16. if (data.IsWaitingAsyncResult)
  17. DoProgressBar(rect, data.ProgressMessage, data.ProgressPercent);
  18. }
  19. static void DoProgressBar(
  20. Rect rect,
  21. string progressMessage,
  22. float progressPercent)
  23. {
  24. Rect messageRect = new Rect(
  25. rect.xMin, rect.yMin + 2, rect.width, 16);
  26. Rect progresRect = new Rect(
  27. rect.xMin, rect.yMin + 20, rect.width, 6);
  28. GUI.Label(messageRect, progressMessage);
  29. EditorGUI.ProgressBar(progresRect, progressPercent, string.Empty);
  30. }
  31. }
  32. }