源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.7 KiB

преди 1 месец
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Assets.Editor.Treemap;
  6. using MemoryProfilerWindow;
  7. using UnityEditor;
  8. using UnityEngine;
  9. namespace Treemap
  10. {
  11. public class Group : IComparable<Group>, ITreemapRenderable
  12. {
  13. public string _name;
  14. public Rect _position;
  15. public List<Item> _items;
  16. private float _totalMemorySize = -1;
  17. public float totalMemorySize
  18. {
  19. get
  20. {
  21. if (_totalMemorySize != -1)
  22. return _totalMemorySize;
  23. long result = 0;
  24. foreach (Item item in _items)
  25. {
  26. result += item.memorySize;
  27. }
  28. _totalMemorySize = result;
  29. return result;
  30. }
  31. }
  32. public float[] memorySizes
  33. {
  34. get
  35. {
  36. float[] result = new float[_items.Count];
  37. for (int i = 0; i < _items.Count; i++)
  38. {
  39. result[i] = _items[i].memorySize;
  40. }
  41. return result;
  42. }
  43. }
  44. public Color color
  45. {
  46. get { return Utility.GetColorForName(_name); }
  47. }
  48. public int CompareTo(Group other)
  49. {
  50. return (int)(other.totalMemorySize - totalMemorySize);
  51. }
  52. public Color GetColor()
  53. {
  54. return color;
  55. }
  56. public Rect GetPosition()
  57. {
  58. return _position;
  59. }
  60. public string GetLabel()
  61. {
  62. string row1 = _name;
  63. string row2 = EditorUtility.FormatBytes((long)totalMemorySize);
  64. return row1 + "\n" + row2;
  65. }
  66. }
  67. }