public override void OnGUI(Rect position, int column) { if (column == 0) { HeEditorGUI.ManagedTypeIcon(HeEditorGUI.SpaceL(ref position, position.height), m_Type.packed); } switch ((Column)column) { case Column.Name: HeEditorGUI.TypeName(position, typeName); break; case Column.Size: HeEditorGUI.Size(position, size); break; case Column.ValueType: EditorGUI.ToggleLeft(position, GUIContent.none, isValueType); break; case Column.AssemblyName: HeEditorGUI.AssemblyName(position, assemblyName); break; } }
public override void OnGUI(Rect position, int column) { if (column == 0) { if (HeEditorGUI.CppButton(HeEditorGUI.SpaceL(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(m_NativeObject)); } if (m_NativeObject.gcHandle.isValid) { if (HeEditorGUI.GCHandleButton(HeEditorGUI.SpaceR(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(m_NativeObject.gcHandle)); } } if (m_NativeObject.managedObject.isValid) { if (HeEditorGUI.CsButton(HeEditorGUI.SpaceR(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(m_NativeObject.managedObject)); } } } base.OnGUI(position, column); }
public override void OnGUI(Rect position, int column) { if (column == 0) { GUI.Box(HeEditorGUI.SpaceL(ref position, position.height), HeEditorStyles.csStaticImage, HeEditorStyles.iconStyle); } switch ((Column)column) { case Column.Type: HeEditorGUI.TypeName(position, typeName); break; case Column.Size: HeEditorGUI.Size(position, size); break; case Column.Refs: GUI.Label(position, referencesCount.ToString()); break; case Column.Assembly: GUI.Label(position, assemblyName); break; } }
public static void ManagedTypeIcon(Rect position, PackedManagedType type) { var isValueType = type.isValueType; var icon = isValueType ? HeEditorStyles.csValueTypeImage : HeEditorStyles.csReferenceTypeImage; var content = new GUIContent(icon, isValueType ? "ValueType" : "ReferenceType"); GUI.Box(HeEditorGUI.SpaceL(ref position, position.height), content, HeEditorStyles.iconStyle); }
void DrawStats(string field1, string field2, string field3) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label(field1, GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(field2, GUILayout.Width(k_ColumnSizeWidth)); HeEditorGUI.TypeName(GUILayoutUtility.GetRect(10, GUI.skin.label.CalcHeight(new GUIContent("Wg"), 32), GUILayout.ExpandWidth(true)), field3); } }
public override void OnGUI(Rect position, int column) { if (column == 0) { if (HeEditorGUI.CsButton(HeEditorGUI.SpaceL(ref position, position.height))) { MemoryWindow.Inspect(m_Snapshot, address, size); } } base.OnGUI(position, column); }
public override void OnGUI(Rect position, int column) { if (column == 0) { if (HeEditorGUI.CsStaticButton(HeEditorGUI.SpaceL(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(new RichStaticField(m_Snapshot, m_StaticField.staticFieldsArrayIndex))); } } base.OnGUI(position, column); }
public override void OnGUI(Rect position, int column) { if (column == 0) { GUI.Box(HeEditorGUI.SpaceL(ref position, position.height), HeEditorStyles.csImage, HeEditorStyles.iconStyle); //if (m_managedObject.gcHandlesArrayIndex != -1) //{ // if (HeEditorGUI.GCHandleButton(HeEditorGUI.SpaceR(ref position, position.height))) // { // m_owner.m_Window.OnGoto(new GotoCommand(new RichGCHandle(m_snapshot, m_snapshot.gcHandles[m_managedObject.gcHandlesArrayIndex]))); // } //} if (m_Object.nativeObject.isValid) { if (HeEditorGUI.CppButton(HeEditorGUI.SpaceR(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(m_Object.nativeObject)); } } } switch ((Column)column) { case Column.Type: HeEditorGUI.TypeName(position, typeName); break; case Column.CppCounterpart: if (m_Object.nativeObject.isValid) { GUI.Label(position, m_Object.nativeObject.name); } break; case Column.Size: HeEditorGUI.Size(position, size); break; case Column.Address: HeEditorGUI.Address(position, m_Object.address); break; case Column.Assembly: GUI.Label(position, assembly); break; } }
public override void OnGUI(Rect position, int column) { switch ((Column)column) { case Column.GCHandle: HeEditorGUI.TypeName(position, typeName); break; case Column.Size: HeEditorGUI.Size(position, size); break; case Column.Count: GUI.Label(position, count.ToString()); break; } }
void TryDrawObjectButton(PropertyGridItem itm, ref Rect rect) { // We do not test against address==0 here, because if it is a static field its address might be 0 if (itm.type.managedTypesArrayIndex < 0 || (itm is BaseClassPropertyGridItem)) { return; } // If it is not a pointer, it does not point to another object //var type = m_snapshot.managedTypes[itm.typeIndex]; if (!itm.type.isPointer) { return; } // If it points to null, it has no object var pointer = itm.myMemoryReader.ReadPointer(itm.address); if (pointer == 0) { return; } // Check if it is a managed object var managedObjIndex = m_Snapshot.FindManagedObjectOfAddress(itm.type.isArray ? itm.address : pointer); if (managedObjIndex != -1) { if (HeEditorGUI.CsButton(HeEditorGUI.SpaceR(ref rect, rect.height))) { m_Owner.window.OnGoto(new GotoCommand(new RichManagedObject(m_Snapshot, managedObjIndex))); } } // Check if it is a native object var nativeObjIndex = m_Snapshot.FindNativeObjectOfAddress(pointer); if (nativeObjIndex != -1) { if (HeEditorGUI.CppButton(HeEditorGUI.SpaceR(ref rect, rect.height))) { m_Owner.window.OnGoto(new GotoCommand(new RichNativeObject(m_Snapshot, nativeObjIndex))); } } }
public override void OnGUI(Rect position, int column) { switch ((Column)column) { case Column.Address: HeEditorGUI.Address(position, address); break; case Column.Size: HeEditorGUI.Size(position, (long)size); break; #if HEAPEXPLORER_DISPLAY_REFS case Column.Refs: GUI.Label(position, refs.ToString()); break; #endif } }
public override void OnGUI(Rect position, int column) { switch ((Column)column) { case Column.Type: HeEditorGUI.TypeName(position, displayName, m_Tooltip); break; case Column.Name: EditorGUI.LabelField(position, m_Value); break; case Column.Address: if (address != 0) // statics dont have an address in PackedMemorySnapshot and I don't want to display a misleading 0 { HeEditorGUI.Address(position, address); } break; } }
public override void OnGUI(Rect position, int column) { if (column == 0 && depth == 0) { switch (rootPath.reason) { case RootPathReason.Static: case RootPathReason.DontDestroyOnLoad: case RootPathReason.DontUnloadUnusedAsset: case RootPathReason.UnityManager: GUI.Box(HeEditorGUI.SpaceL(ref position, position.height), new GUIContent(HeEditorStyles.warnImage, rootPath.reasonString), HeEditorStyles.iconStyle); break; } } switch ((Column)column) { case Column.Type: HeEditorGUI.TypeName(position, displayName); break; case Column.Name: EditorGUI.LabelField(position, m_Value); break; case Column.Address: if (m_Address != 0) // statics dont have an address in PackedMemorySnapshot and I don't want to display a misleading 0 { HeEditorGUI.Address(position, m_Address); } break; case Column.Depth: if (rootPath != null) { EditorGUI.LabelField(position, rootPath.count.ToString()); } break; } }
public override void OnGUI(Rect position, int column) { if (column == 0) { GUI.Box(HeEditorGUI.SpaceL(ref position, position.height), HeEditorStyles.gcHandleImage, HeEditorStyles.iconStyle); if (m_GCHandle.nativeObject.isValid) { if (HeEditorGUI.CppButton(HeEditorGUI.SpaceR(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(m_GCHandle.nativeObject)); } } if (m_GCHandle.managedObject.isValid) { if (HeEditorGUI.CsButton(HeEditorGUI.SpaceR(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(m_GCHandle.managedObject)); } } } switch ((Column)column) { case Column.GCHandle: HeEditorGUI.TypeName(position, typeName); break; case Column.Size: HeEditorGUI.Size(position, size); break; case Column.Address: HeEditorGUI.Address(position, address); break; } }
public override void OnGUI(Rect position, int column) { if (column == 0 && this.icon != null) { GUI.Box(HeEditorGUI.SpaceL(ref position, position.height), this.icon, HeEditorStyles.iconStyle); } switch ((EColumn)column) { case EColumn.Type: HeEditorGUI.TypeName(position, displayName ?? k_UnknownTypeString); break; case EColumn.SizeA: HeEditorGUI.Size(position, size[0]); break; case EColumn.SizeB: HeEditorGUI.Size(position, size[1]); break; case EColumn.SizeDiff: HeEditorGUI.SizeDiff(position, sizeDiff); break; case EColumn.CountA: HeEditorGUI.Count(position, count[0]); break; case EColumn.CountB: HeEditorGUI.Count(position, count[1]); break; case EColumn.CountDiff: HeEditorGUI.CountDiff(position, countDiff); break; } }
void TryDrawDataVisualizerButton(PropertyGridItem itm, ref Rect rect) { if (!enabled || type.managedTypesArrayIndex == -1) { return; } if (!AbstractDataVisualizer.HasVisualizer(type.name)) { return; } if (GUI.Button(HeEditorGUI.SpaceR(ref rect, rect.height), new GUIContent("", "Show in Data Visualizer."), HeEditorStyles.dataVisualizer)) { var pointer = address; if (type.isPointer) { pointer = myMemoryReader.ReadPointer(address); } DataVisualizerWindow.CreateWindow(m_Snapshot, myMemoryReader, pointer, type); } }
public override void OnGUI(Rect position, int column) { position.width -= 2; position.x += 1; position.height -= 2; position.y += 1; //var oldcolor = GUI.color; //if (!enabled) // GUI.color = new Color(oldcolor.r, oldcolor.g, oldcolor.b, oldcolor.a * 0.5f); if (column == 0 && icon != null) { GUI.Box(HeEditorGUI.SpaceL(ref position, position.height), icon, HeEditorStyles.iconStyle); } switch ((PropertyGridColumn)column) { case PropertyGridColumn.Type: GUI.Label(position, displayType); break; case PropertyGridColumn.Name: TryDrawObjectButton(this, ref position); GUI.Label(position, new GUIContent(displayName, tooltip)); break; case PropertyGridColumn.Value: TryDrawDataVisualizerButton(this, ref position); GUI.Label(position, displayValue); break; } //if (!enabled) // GUI.color = oldcolor; }
public override void OnGUI(Rect position, int column) { if (column == 0) { HeEditorGUI.NativeObjectIcon(HeEditorGUI.SpaceL(ref position, position.height), m_Object.packed); if (m_Object.managedObject.isValid) { if (HeEditorGUI.CsButton(HeEditorGUI.SpaceR(ref position, position.height))) { m_Owner.window.OnGoto(new GotoCommand(m_Object.managedObject)); } } } switch ((Column)column) { case Column.Type: GUI.Label(position, typeName); break; case Column.Name: { GUI.Label(position, name); var e = Event.current; if (e.type == EventType.ContextClick && position.Contains(e.mousePosition)) { var menu = new GenericMenu(); OnShowNameContextMenu(menu); if (menu.GetItemCount() > 0) { e.Use(); menu.ShowAsContext(); } } } break; case Column.Size: HeEditorGUI.Size(position, size); break; case Column.Address: HeEditorGUI.Address(position, address); break; case Column.DontDestroyOnLoad: GUI.Label(position, isDontDestroyOnLoad.ToString()); break; case Column.IsPersistent: GUI.Label(position, isPersistent.ToString()); break; case Column.InstanceID: GUI.Label(position, instanceId.ToString()); break; #if HEAPEXPLORER_DISPLAY_REFS case Column.ReferencesCount: GUI.Label(position, m_ReferencesCount.ToString()); break; case Column.ReferencedByCount: GUI.Label(position, m_ReferencedByCount.ToString()); break; #endif } }
public override void OnGUI() { base.OnGUI(); float k_CellWidth = window.position.width * 0.328f; GUILayout.Label("Brief Overview", HeEditorStyles.heading2); GUILayout.Space(8); using (new EditorGUILayout.HorizontalScope()) { // Native Memory using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(k_CellWidth))) { EditorGUILayout.LabelField(new GUIContent(string.Format("Top {0} Native Memory Usage", k_ListItemCount), HeEditorStyles.cppImage), EditorStyles.boldLabel); GUILayout.Space(8); for (var n = 0; n < Mathf.Min(k_ListItemCount, m_NativeMemory.Length); ++n) { var type = snapshot.nativeTypes[m_NativeMemory[n].typeIndex]; var size = m_NativeMemory[n].size; using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label(string.Format("{0:F2}%", (size / (float)m_NativeMemoryTotal) * 100), GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(EditorUtility.FormatBytes(size), GUILayout.Width(k_ColumnSizeWidth)); HeEditorGUI.TypeName(GUILayoutUtility.GetRect(10, GUI.skin.label.CalcHeight(new GUIContent("Wg"), 32), GUILayout.ExpandWidth(true)), type.name); } } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("", GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label("...", GUILayout.Width(k_ColumnSizeWidth)); } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("Total", GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(EditorUtility.FormatBytes(m_NativeMemoryTotal), EditorStyles.boldLabel, GUILayout.Width(k_ColumnSizeWidth)); if (GUILayout.Button("Investigate")) { window.OnGoto(new GotoCommand(new RichNativeObject(snapshot, 0))); } } } // Managed Memory using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(k_CellWidth))) { EditorGUILayout.LabelField(new GUIContent(string.Format("Top {0} Managed Memory Usage", k_ListItemCount), HeEditorStyles.csImage), EditorStyles.boldLabel); GUILayout.Space(8); for (var n = 0; n < Mathf.Min(k_ListItemCount, m_ManagedMemory.Length); ++n) { var type = snapshot.managedTypes[m_ManagedMemory[n].typeIndex]; var size = m_ManagedMemory[n].size; using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label(string.Format("{0:F2}%", (size / (float)m_ManagedMemoryTotal) * 100), GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(EditorUtility.FormatBytes(size), GUILayout.Width(k_ColumnSizeWidth)); HeEditorGUI.TypeName(GUILayoutUtility.GetRect(10, GUI.skin.label.CalcHeight(new GUIContent("Wg"), 32), GUILayout.ExpandWidth(true)), type.name); } } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("", GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label("...", GUILayout.Width(k_ColumnSizeWidth)); } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("Total", GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(EditorUtility.FormatBytes(m_ManagedMemoryTotal), EditorStyles.boldLabel, GUILayout.Width(k_ColumnSizeWidth)); if (GUILayout.Button("Investigate")) { window.OnGoto(new GotoCommand(new RichManagedObject(snapshot, 0))); } } } // Static Memory using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(k_CellWidth))) { EditorGUILayout.LabelField(new GUIContent(string.Format("Top {0} Static Memory Usage", k_ListItemCount), HeEditorStyles.csStaticImage), EditorStyles.boldLabel); GUILayout.Space(8); for (var n = 0; n < Mathf.Min(k_ListItemCount, m_StaticMemory.Length); ++n) { var type = snapshot.managedTypes[m_StaticMemory[n].typeIndex]; var size = m_StaticMemory[n].size; using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label(string.Format("{0:F2}%", (size / (float)m_StaticMemoryTotal) * 100), GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(EditorUtility.FormatBytes(size), GUILayout.Width(k_ColumnSizeWidth)); HeEditorGUI.TypeName(GUILayoutUtility.GetRect(10, GUI.skin.label.CalcHeight(new GUIContent("Wg"), 32), GUILayout.ExpandWidth(true)), type.name); } } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("", GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label("...", GUILayout.Width(k_ColumnSizeWidth)); } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("Total", GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(EditorUtility.FormatBytes(m_StaticMemoryTotal), EditorStyles.boldLabel, GUILayout.Width(k_ColumnSizeWidth)); if (GUILayout.Button("Investigate")) { window.OnGoto(new GotoCommand(new RichStaticField(snapshot, 0))); } } } } using (new EditorGUILayout.HorizontalScope()) { // GC Handles using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(k_CellWidth))) { EditorGUILayout.LabelField(new GUIContent("GC handles Memory Usage", HeEditorStyles.gcHandleImage), EditorStyles.boldLabel); GUILayout.Space(8); using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("Total", GUILayout.Width(k_ColumnPercentageWidth)); GUILayout.Label(EditorUtility.FormatBytes(snapshot.virtualMachineInformation.pointerSize * snapshot.gcHandles.Length), EditorStyles.boldLabel, GUILayout.Width(k_ColumnSizeWidth)); if (GUILayout.Button("Investigate")) { window.OnGoto(new GotoCommand(new RichGCHandle(snapshot, 0))); } } } // VirtualMachine Information using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(k_CellWidth))) { GUILayout.Label("Virtual Machine Information", EditorStyles.boldLabel); GUILayout.Space(8); DrawStats("", EditorUtility.FormatBytes(snapshot.virtualMachineInformation.pointerSize), "Pointer Size"); DrawStats("", EditorUtility.FormatBytes(snapshot.virtualMachineInformation.objectHeaderSize), "Object Header Size"); DrawStats("", EditorUtility.FormatBytes(snapshot.virtualMachineInformation.arrayHeaderSize), "Array Header Size"); DrawStats("", EditorUtility.FormatBytes(snapshot.virtualMachineInformation.arrayBoundsOffsetInHeader), "Array Bounds Offset In Header"); DrawStats("", EditorUtility.FormatBytes(snapshot.virtualMachineInformation.arraySizeOffsetInHeader), "Array Size Offset In Header"); DrawStats("", EditorUtility.FormatBytes(snapshot.virtualMachineInformation.allocationGranularity), "Allocation Granularity"); DrawStats("", string.Format("{0}", snapshot.virtualMachineInformation.heapFormatVersion), "Heap Format Version"); } } //DrawHeapFragmentation(); }
public override void OnGUI() { base.OnGUI(); using (new EditorGUILayout.HorizontalScope()) { using (new EditorGUILayout.VerticalScope()) { // Native objects list at the left side using (new EditorGUILayout.VerticalScope(HeEditorStyles.panel)) { using (new EditorGUILayout.HorizontalScope()) { OnDrawHeader(); if (m_SearchField.OnToolbarGUI()) { m_NativeObjectsControl.Search(m_SearchField.text); } } GUILayout.Space(2); m_NativeObjectsControl.OnGUI(); } m_SplitterVert = HeEditorGUILayout.VerticalSplitter("m_splitterVert".GetHashCode(), m_SplitterVert, 0.1f, 0.8f, window); using (new EditorGUILayout.HorizontalScope(GUILayout.Height(window.position.height * m_SplitterVert))) { m_ConnectionsView.OnGUI(); } } m_SplitterHorz = HeEditorGUILayout.HorizontalSplitter("m_splitterHorz".GetHashCode(), m_SplitterHorz, 0.1f, 0.8f, window); // Various panels at the right side using (new EditorGUILayout.VerticalScope(GUILayout.Width(window.position.width * m_SplitterHorz))) { using (new EditorGUILayout.VerticalScope(HeEditorStyles.panel)) { using (new EditorGUILayout.HorizontalScope(GUILayout.MaxWidth(16))) { if (m_Selected.HasValue) { HeEditorGUI.NativeObjectIcon(GUILayoutUtility.GetRect(16, 16), m_Selected.Value); //GUI.DrawTexture(r, HeEditorStyles.assetImage); } EditorGUILayout.LabelField("Native UnityEngine object", EditorStyles.boldLabel); } GUILayout.Space(2); m_NativeObjectControl.OnGUI(); } m_PreviewSplitterVert = HeEditorGUILayout.VerticalSplitter("m_PreviewSplitterVert".GetHashCode(), m_PreviewSplitterVert, 0.1f, 0.8f, window); using (new EditorGUILayout.VerticalScope(HeEditorStyles.panel, GUILayout.Height(window.position.height * m_PreviewSplitterVert))) { m_PreviewView.OnGUI(); } m_RootPathSplitterVert = HeEditorGUILayout.VerticalSplitter("m_RootPathSplitterVert".GetHashCode(), m_RootPathSplitterVert, 0.1f, 0.8f, window); using (new EditorGUILayout.VerticalScope(HeEditorStyles.panel, GUILayout.Height(window.position.height * m_RootPathSplitterVert))) { m_RootPathView.OnGUI(); } } } }