少年修仙传客户端基础资源
leonard Wu
2018-08-08 a1fd98c6ae0854327472b369f2bc63fc3ad1d897
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.Editor.Treemap;
using MemoryProfilerWindow;
using UnityEditor;
using UnityEngine;
 
namespace Treemap
{
    public class Group : IComparable<Group>, ITreemapRenderable
    {
        public string _name;
        public Rect _position;
        public List<Item> _items;
        private float _totalMemorySize = -1;
 
        public float totalMemorySize
        {
            get
            {
                if (_totalMemorySize != -1)
                    return _totalMemorySize;
 
                long result = 0;
                foreach (Item item in _items)
                {
                    result += item.memorySize;
                }
                _totalMemorySize = result;
                return result;
            }
        }
 
        public float[] memorySizes
        {
            get
            {
                float[] result = new float[_items.Count];
                for (int i = 0; i < _items.Count; i++)
                {
                    result[i] = _items[i].memorySize;
                }
                return result;
            }
        }
 
        public Color color
        {
            get { return Utility.GetColorForName(_name); }
        }
 
        public int CompareTo(Group other)
        {
            return (int)(other.totalMemorySize - totalMemorySize);
        }
 
        public Color GetColor()
        {
            return color;
        }
 
        public Rect GetPosition()
        {
            return _position;
        }
 
        public string GetLabel()
        {
            string row1 = string.Format("{0} ({1})", _name, _items != null ? _items.Count : 0);
            string row2 = EditorUtility.FormatBytes((long)totalMemorySize);
            return row1 + "\n" + row2;
        }
    }
}