ThreadSelection.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. namespace UnityEditor.Performance.ProfileAnalyzer
  4. {
  5. [Serializable]
  6. internal class ThreadSelection
  7. {
  8. public List<string> groups;
  9. public List<string> selection;
  10. public bool empty
  11. {
  12. get
  13. {
  14. return groups == null || selection == null || groups.Count == 0 && selection.Count == 0;
  15. }
  16. }
  17. public ThreadSelection()
  18. {
  19. groups = new List<string>();
  20. selection = new List<string>();
  21. }
  22. public ThreadSelection(ThreadSelection threadSelection)
  23. {
  24. groups = new List<string>();
  25. selection = new List<string>();
  26. Set(threadSelection);
  27. }
  28. public void SetAll()
  29. {
  30. groups.Clear();
  31. selection.Clear();
  32. ThreadIdentifier allThreadSelection = new ThreadIdentifier("All", ThreadIdentifier.kAll);
  33. groups.Add(allThreadSelection.threadNameWithIndex);
  34. }
  35. public void Set(string name)
  36. {
  37. groups.Clear();
  38. selection.Clear();
  39. selection.Add(name);
  40. }
  41. public void SetGroup(string groupName)
  42. {
  43. groups.Clear();
  44. selection.Clear();
  45. ThreadIdentifier allThreadSelection = new ThreadIdentifier(groupName, ThreadIdentifier.kAll);
  46. groups.Add(allThreadSelection.threadNameWithIndex);
  47. }
  48. public void Set(ThreadSelection threadSelection)
  49. {
  50. groups.Clear();
  51. selection.Clear();
  52. if (threadSelection.groups != null)
  53. groups.AddRange(threadSelection.groups);
  54. if (threadSelection.selection != null)
  55. selection.AddRange(threadSelection.selection);
  56. }
  57. }
  58. }