public MemoryMapDiffPane(UIState s, IViewPaneEventListener l, VisualElement toolbarExtension) : base(s, l) { CurrentTableView = (TableDisplayMode)UnityEditor.EditorPrefs.GetInt("Unity.MemoryProfiler.Editor.UI.MemoryMapPaneDiff.TableDisplayMode", (int)TableDisplayMode.Regions); m_ToolbarExtension = toolbarExtension; m_ToolbarExtensionPane = new IMGUIContainer(new Action(OnGUIToolbarExtension)); s.CurrentMode.ViewPaneChanged += OnViewPaneChanged; s.ModeChanged += OnModeChanged; string[] displayElements = Enum.GetNames(typeof(MemoryMap.MemoryMapDiff.DisplayElements)); m_DisplayElementsList = new GUIContent[displayElements.Length]; for (int i = 0; i < displayElements.Length; ++i) m_DisplayElementsList[i] = new GUIContent(displayElements[i]); string[] colorSchemes = Enum.GetNames(typeof(MemoryMap.MemoryMapDiff.ColorScheme)); m_ColorSchemeList = new GUIContent[colorSchemes.Length]; for (int i = 0; i < colorSchemes.Length; ++i) m_ColorSchemeList[i] = new GUIContent(colorSchemes[i]); ulong maxSize = 256 * 1024 * 1024; // 256,128, 64,32,16,8, 4,2,1,512, 256,128,64,32 m_BytesInRowList = new RowSize[14]; for (int i = 0; i < m_BytesInRowList.Length; ++i) m_BytesInRowList[i] = new RowSize(maxSize >> i); UIState.SnapshotMode mode1 = m_UIState.FirstMode as UIState.SnapshotMode; UIState.SnapshotMode mode2 = m_UIState.SecondMode as UIState.SnapshotMode; m_ActiveMode = mode1; m_MemoryMap = new MemoryMap.MemoryMapDiff(); m_MemoryMap.Setup(mode1.snapshot, mode2.snapshot); m_MemoryMap.RegionSelected += OnSelectRegions; }
public override void OnClose() { m_MemoryMap.Dispose(); m_MemoryMap = null; m_Spreadsheet = null; m_ActiveMode = null; if (m_ToolbarExtensionMode != null) m_ToolbarExtensionMode.ViewPaneChanged -= OnViewPaneChanged; m_ToolbarExtensionMode = null; }
void OnGUISpreadsheet(Rect r) { GUILayout.BeginArea(r); int currentTableView = (int)CurrentTableView; EditorGUILayout.BeginHorizontal(MemoryMapBase.Styles.ContentToolbar); if (GUILayout.Toggle(m_ActiveMode == m_UIState.FirstMode, "Snapshot A", EditorStyles.radioButton)) { if (m_ActiveMode != m_UIState.FirstMode) { m_ActiveMode = m_UIState.FirstMode as UIState.SnapshotMode; m_MemoryMap.Reselect(); } } if (GUILayout.Toggle(m_ActiveMode == m_UIState.SecondMode, "Snapshot B", EditorStyles.radioButton)) { if (m_ActiveMode != m_UIState.SecondMode) { m_ActiveMode = m_UIState.SecondMode as UIState.SnapshotMode; m_MemoryMap.Reselect(); } } if (r.width > 500) { GUILayout.Space(r.width - 500); } var popupRect = GUILayoutUtility.GetRect(Content.TableModesList[currentTableView], EditorStyles.toolbarPopup); if (EditorGUI.DropdownButton(popupRect, Content.TableModesList[currentTableView], FocusType.Passive, EditorStyles.toolbarPopup)) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < Content.TableModesList.Length; i++) { menu.AddItem(Content.TableModesList[i], (int)currentTableView == i, (object data) => { CurrentTableView = (TableDisplayMode)data; m_MemoryMap.Reselect(); }, i); } menu.DropDown(popupRect); } EditorGUILayout.EndHorizontal(); if (m_Spreadsheet != null) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(2); m_Spreadsheet.OnGUI(r.width - 4); GUILayout.Space(2); EditorGUILayout.EndHorizontal(); GUILayout.Space(2); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); }