Example #1
0
 public override void Draw(Rect area)
 {
     GUILayout.BeginArea(area);
     scrollPosition = GUILayout.BeginScrollView(scrollPosition);
     if (selectedNode == null)
     {
         GUILayout.Label("Select an object to see more info");
     }
     else
     {
         EditorGUILayout.LabelField(string.Format("Name: {0}", selectedNode.GetName(0)));
         EditorGUILayout.LabelField(string.Format("Other Name: "));
         selectedNode.GetDistinctName().ForEach(c => EditorGUILayout.LabelField("    " + c));
         EditorGUILayout.LabelField(string.Format("Type: {0}", selectedNode.type.ToString()));
         EditorGUILayout.LabelField(string.Format("Size: {0} ({1} Byte)", EditorUtility.FormatBytes(selectedNode.thisNodeSize), selectedNode.thisNodeSize.ToString()));
         EditorGUILayout.LabelField(string.Format("TotalSize: {0} ({1} Byte)", EditorUtility.FormatBytes(selectedNode.totalSize), selectedNode.totalSize.ToString()));
         EditorGUILayout.LabelField("Reference: ");
         foreach (SnapshotNode child in selectedNode.children)
         {
             if (GUILayout.Button(child.GetName(selectedNode.id)))
             {
                 if (NodeChangeEvent != null)
                 {
                     NodeChangeEvent(child);
                 }
             }
         }
         EditorGUILayout.LabelField("Reference By: ");
         foreach (long parent in selectedNode.parents)
         {
             if (!snapshot.index.ContainsKey(parent))
             {
                 continue;
             }
             SnapshotNode node = snapshot.index[parent];
             if (GUILayout.Button(node.GetName(selectedNode.id)))
             {
                 if (NodeChangeEvent != null)
                 {
                     NodeChangeEvent(node);
                 }
             }
         }
     }
     GUILayout.EndScrollView();
     GUILayout.EndArea();
 }
Example #2
0
        protected void Draw(SnapshotNode node, long parentId)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(" ", GUILayout.Width(10));
            EditorGUILayout.BeginVertical();
            string text = string.Format("{0}  size:{1}({2}B)  total size:{3}({4}B)",
                                        node.GetName(parentId),
                                        EditorUtility.FormatBytes(node.thisNodeSize),
                                        node.thisNodeSize,
                                        EditorUtility.FormatBytes(node.totalSize),
                                        node.totalSize);
            bool isFold = true;

            if (node.children.Count > 0)
            {
                if (isFoldSet.Contains(node))
                {
                    isFold = false;
                }
                isFold = !EditorGUILayout.Foldout(!isFold, text);
                if (!isFold)
                {
                    isFoldSet.Add(node);
                }
                else
                {
                    if (isFoldSet.Contains(node))
                    {
                        isFoldSet.Remove(node);
                    }
                }
            }
            else
            {
                EditorGUILayout.LabelField(text);
            }
            if (!isFold)
            {
                for (int i = 0; i < node.children.Count; i++)
                {
                    Draw(node.children[i], node.id);
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }