示例#1
0
        private void RefreshCachedRects(bool fullRefresh)
        {
            Rect space = new Rect(-100f, -100f, 200f, 200f);

            if (fullRefresh)
            {
                List <MemoryProfilerTreemap.Group> groups = _groups.Values.ToList();
                groups.Sort();
                float[] groupTotalValues = new float[groups.Count];
                for (int i = 0; i < groups.Count; i++)
                {
                    groupTotalValues[i] = groups.ElementAt(i).totalMemorySize;
                }

                Rect[] groupRects = Utility.GetTreemapRects(groupTotalValues, space);
                for (int groupIndex = 0; groupIndex < groupRects.Length; groupIndex++)
                {
                    MemoryProfilerTreemap.Group group = groups[groupIndex];
                    group._position = groupRects[groupIndex];
                }
            }

            if (_selectedGroup != null)
            {
                Rect[] rects = Utility.GetTreemapRects(_selectedGroup.memorySizes, _selectedGroup._position);

                for (int i = 0; i < rects.Length; i++)
                {
                    _selectedGroup._items[i]._position = rects[i];
                }
            }

            RefreshMesh();
        }
示例#2
0
        void RefreshCaches()
        {
            _items.Clear();
            _groups.Clear();

            foreach (ThingInMemory thingInMemory in _unpackedCrawl.allObjects)
            {
                string groupName = GetGroupName(thingInMemory);
                if (groupName.Length == 0)
                {
                    continue;
                }

                if (!_groups.ContainsKey(groupName))
                {
                    MemoryProfilerTreemap.Group newGroup = new MemoryProfilerTreemap.Group();
                    newGroup._name  = groupName;
                    newGroup._items = new List <Item>();
                    _groups.Add(groupName, newGroup);
                }

                Item item = new Item(thingInMemory, _groups[groupName]);
                _items.Add(item);
                _groups[groupName]._items.Add(item);
            }

            foreach (MemoryProfilerTreemap.Group group in _groups.Values)
            {
                group._items.Sort();
            }

            _items.Sort();
            RefreshCachedRects(true);
        }
示例#3
0
        private void RenderGroupLabel(MemoryProfilerTreemap.Group group)
        {
            Matrix4x4 mat = _ZoomArea.drawingToViewMatrix;

            Vector3 p1 = mat.MultiplyPoint(new Vector3(group._position.xMin, group._position.yMin));
            Vector3 p2 = mat.MultiplyPoint(new Vector3(group._position.xMax, group._position.yMax));

            if (p2.x - p1.x > 30f)
            {
                Rect rect = new Rect(p1.x, p2.y, p2.x - p1.x, p1.y - p2.y);
                GUI.Label(rect, group.GetLabel());
            }
        }
示例#4
0
        private void RenderGroupItems(MemoryProfilerTreemap.Group group)
        {
            Matrix4x4 mat = _ZoomArea.drawingToViewMatrix;

            foreach (Item item in group._items)
            {
                if (Utility.IsInside(item._position, _ZoomArea.shownArea))
                {
                    Vector3 p1 = mat.MultiplyPoint(new Vector3(item._position.xMin, item._position.yMin));
                    Vector3 p2 = mat.MultiplyPoint(new Vector3(item._position.xMax, item._position.yMax));

                    if (p2.x - p1.x > 30f)
                    {
                        Rect   rect = new Rect(p1.x, p2.y, p2.x - p1.x, p1.y - p2.y);
                        string row1 = item._group._name;
                        string row2 = EditorUtility.FormatBytes(item.memorySize);
                        GUI.Label(rect, row1 + "\n" + row2);
                    }
                }
            }
        }
示例#5
0
        private void HandleMouseClick()
        {
            if ((Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseUp) && Event.current.button == 0)
            {
                if (_ZoomArea.drawRect.Contains(Event.current.mousePosition))
                {
                    MemoryProfilerTreemap.Group group = _groups.Values.FirstOrDefault(i => i._position.Contains(mouseTreemapPosition));
                    Item item = _items.FirstOrDefault(i => i._position.Contains(mouseTreemapPosition));

                    if (item != null && _selectedGroup == item._group)
                    {
                        switch (Event.current.type)
                        {
                        case EventType.MouseDown:
                            _mouseDownItem = item;
                            break;

                        case EventType.MouseUp:
                            if (_mouseDownItem == item)
                            {
                                _hostWindow.SelectThing(item._thingInMemory);
                                Event.current.Use();
                            }
                            break;
                        }
                    }
                    else if (group != null)
                    {
                        switch (Event.current.type)
                        {
                        case EventType.MouseUp:
                            _hostWindow.SelectGroup(group);
                            Event.current.Use();
                            break;
                        }
                    }
                }
            }
        }
示例#6
0
 public void SelectGroup(MemoryProfilerTreemap.Group group)
 {
     _treeMapView.SelectGroup(group);
 }
示例#7
0
 public Item(ThingInMemory thingInMemory, MemoryProfilerTreemap.Group group)
 {
     _thingInMemory = thingInMemory;
     _group         = group;
 }
示例#8
0
 public void SelectGroup(MemoryProfilerTreemap.Group group)
 {
     _selectedItem  = null;
     _selectedGroup = group;
     RefreshCachedRects(false);
 }
示例#9
0
 public void SelectThing(ThingInMemory thing)
 {
     _selectedItem  = _items.First(i => i._thingInMemory == thing);
     _selectedGroup = _selectedItem._group;
     RefreshCachedRects(false);
 }