ProgressBarDisplay.cs 1009 B

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. namespace UnityEditor.Performance.ProfileAnalyzer
  3. {
  4. internal class ProgressBarDisplay
  5. {
  6. int m_TotalFrames;
  7. int m_CurrentFrame;
  8. string m_Title;
  9. string m_Description;
  10. public void InitProgressBar(string title, string description, int frames)
  11. {
  12. m_CurrentFrame = 0;
  13. m_TotalFrames = frames;
  14. m_Title = title;
  15. m_Description = description;
  16. EditorUtility.DisplayProgressBar(m_Title, m_Description, m_CurrentFrame);
  17. }
  18. public void AdvanceProgressBar()
  19. {
  20. m_CurrentFrame++;
  21. int currentFrame = Mathf.Clamp(0, m_CurrentFrame, m_TotalFrames);
  22. float progress = m_TotalFrames > 0 ? (float)currentFrame / m_TotalFrames : 0f;
  23. EditorUtility.DisplayProgressBar(m_Title, m_Description, progress);
  24. }
  25. public void ClearProgressBar()
  26. {
  27. EditorUtility.ClearProgressBar();
  28. }
  29. }
  30. }