void InitIfNeeded() { if (m_Initialized) { return; } var cpuDetailColumns = new[] { ProfilerColumn.ObjectName, ProfilerColumn.TotalPercent, ProfilerColumn.GCMemory, ProfilerColumn.TotalTime }; var gpuDetailColumns = new[] { ProfilerColumn.ObjectName, ProfilerColumn.TotalGPUPercent, ProfilerColumn.DrawCalls, ProfilerColumn.TotalGPUTime }; var profilerColumns = gpuView ? gpuDetailColumns : cpuDetailColumns; var defaultSortColumn = gpuView ? ProfilerColumn.TotalGPUTime : ProfilerColumn.TotalTime; var columns = ProfilerFrameDataHierarchyView.CreateColumns(profilerColumns); var headerState = ProfilerFrameDataHierarchyView.CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn); headerState.columns[0].minWidth = 60; headerState.columns[0].autoResize = true; headerState.columns[0].allowToggleVisibility = false; if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState)) { MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState); } var firstInit = m_MultiColumnHeaderState == null; m_MultiColumnHeaderState = headerState; m_MultiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns) { height = 25 }; if (firstInit) { m_MultiColumnHeader.ResizeToFit(); } if (m_TreeViewState == null) { m_TreeViewState = new TreeViewState(); } m_TreeView = new ObjectsTreeView(m_TreeViewState, m_MultiColumnHeader); m_TreeView.frameItemEvent += frameItemEvent; if (m_VertSplit == null || m_VertSplit.relativeSizes == null || m_VertSplit.relativeSizes.Length == 0) { m_VertSplit = new SplitterState(new[] { 60f, 40f }, new[] { 50, 50 }, null); } m_Initialized = true; }
void InitIfNeeded() { if (m_Initialized) { return; } if (m_CachedCallstack == null) { m_CachedCallstack = new List <ulong>(); } var cpuDetailColumns = new[] { HierarchyFrameDataView.columnObjectName, HierarchyFrameDataView.columnTotalPercent, HierarchyFrameDataView.columnGcMemory, HierarchyFrameDataView.columnTotalTime }; var gpuDetailColumns = new[] { HierarchyFrameDataView.columnObjectName, HierarchyFrameDataView.columnTotalGpuPercent, HierarchyFrameDataView.columnDrawCalls, HierarchyFrameDataView.columnTotalGpuTime }; var profilerColumns = gpuView ? gpuDetailColumns : cpuDetailColumns; var defaultSortColumn = gpuView ? HierarchyFrameDataView.columnTotalGpuTime : HierarchyFrameDataView.columnTotalTime; var columns = ProfilerFrameDataHierarchyView.CreateColumns(profilerColumns); var headerState = ProfilerFrameDataHierarchyView.CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn); headerState.columns[0].minWidth = 60; headerState.columns[0].autoResize = true; headerState.columns[0].allowToggleVisibility = false; var multiColumnHeaderStateData = SessionState.GetString(multiColumnHeaderStatePrefKey, ""); if (!string.IsNullOrEmpty(multiColumnHeaderStateData)) { try { var restoredHeaderState = JsonUtility.FromJson <MultiColumnHeaderState>(multiColumnHeaderStateData); if (restoredHeaderState != null) { m_MultiColumnHeaderState = restoredHeaderState; } } catch {} // Nevermind, we'll just fall back to the default } if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState)) { MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState); } var firstInit = m_MultiColumnHeaderState == null; m_MultiColumnHeaderState = headerState; m_MultiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns) { height = 25 }; if (firstInit) { m_MultiColumnHeader.ResizeToFit(); } m_MultiColumnHeader.visibleColumnsChanged += OnMultiColumnHeaderChanged; m_MultiColumnHeader.sortingChanged += OnMultiColumnHeaderChanged; if (m_TreeViewState == null) { m_TreeViewState = new TreeViewState(); } m_TreeView = new ObjectsTreeView(m_TreeViewState, m_MultiColumnHeader); m_TreeView.frameItemEvent += frameItemEvent; if (m_VertSplit == null || m_VertSplit.relativeSizes == null || m_VertSplit.relativeSizes.Length == 0) { m_VertSplit = new SplitterState(new[] { SessionState.GetFloat(splitter0StatePrefKey, 60f), SessionState.GetFloat(splitter1StatePrefKey, 40f) }, new[] { 50, 50 }, null); } m_Initialized = true; }