public ObjectsTreeView(TreeViewState treeViewState, ProfilerFrameDataMultiColumnHeader multicolumnHeader) : base(treeViewState, multicolumnHeader)
 {
     base.showBorder = true;
     base.showAlternatingRowBackgrounds = true;
     multicolumnHeader.sortingChanged  += new MultiColumnHeader.HeaderCallback(this.OnSortingChanged);
     base.Reload();
 }
 private void InitIfNeeded()
 {
     if (!this.m_Initialized)
     {
         ProfilerColumn[] array = new ProfilerColumn[]
         {
             ProfilerColumn.ObjectName,
             ProfilerColumn.TotalPercent,
             ProfilerColumn.GCMemory,
             ProfilerColumn.TotalTime
         };
         ProfilerColumn[] array2 = new ProfilerColumn[]
         {
             ProfilerColumn.ObjectName,
             ProfilerColumn.TotalGPUPercent,
             ProfilerColumn.DrawCalls,
             ProfilerColumn.TotalGPUTime
         };
         ProfilerColumn[] profilerColumns   = (!this.gpuView) ? array : array2;
         ProfilerColumn   defaultSortColumn = (!this.gpuView) ? ProfilerColumn.TotalTime : ProfilerColumn.TotalGPUTime;
         ProfilerFrameDataMultiColumnHeader.Column[] columns = ProfilerFrameDataHierarchyView.CreateColumns(profilerColumns);
         MultiColumnHeaderState multiColumnHeaderState       = ProfilerFrameDataHierarchyView.CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);
         multiColumnHeaderState.columns[0].minWidth              = 60f;
         multiColumnHeaderState.columns[0].autoResize            = true;
         multiColumnHeaderState.columns[0].allowToggleVisibility = false;
         if (MultiColumnHeaderState.CanOverwriteSerializedFields(this.m_MultiColumnHeaderState, multiColumnHeaderState))
         {
             MultiColumnHeaderState.OverwriteSerializedFields(this.m_MultiColumnHeaderState, multiColumnHeaderState);
         }
         bool flag = this.m_MultiColumnHeaderState == null;
         this.m_MultiColumnHeaderState = multiColumnHeaderState;
         this.m_MultiColumnHeader      = new ProfilerFrameDataMultiColumnHeader(this.m_MultiColumnHeaderState, columns)
         {
             height = 25f
         };
         if (flag)
         {
             this.m_MultiColumnHeader.ResizeToFit();
         }
         if (this.m_TreeViewState == null)
         {
             this.m_TreeViewState = new TreeViewState();
         }
         this.m_TreeView = new ProfilerDetailedObjectsView.ObjectsTreeView(this.m_TreeViewState, this.m_MultiColumnHeader);
         this.m_TreeView.frameItemEvent += this.frameItemEvent;
         if (this.m_VertSplit == null || this.m_VertSplit.relativeSizes == null || this.m_VertSplit.relativeSizes.Length == 0)
         {
             this.m_VertSplit = new SplitterState(new float[]
             {
                 60f,
                 40f
             }, new int[]
             {
                 50,
                 50
             }, null);
         }
         this.m_Initialized = true;
     }
 }
예제 #3
0
            public ObjectsTreeView(TreeViewState treeViewState, ProfilerFrameDataMultiColumnHeader multicolumnHeader)
                : base(treeViewState, multicolumnHeader)
            {
                showBorder = true;
                showAlternatingRowBackgrounds     = true;
                multicolumnHeader.sortingChanged += OnSortingChanged;

                Reload();
            }
예제 #4
0
        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;
        }
        public static MultiColumnHeaderState CreateDefaultMultiColumnHeaderState(ProfilerFrameDataMultiColumnHeader.Column[] columns, int defaultSortColumn)
        {
            var headerColumns = new MultiColumnHeaderState.Column[columns.Length];

            for (var i = 0; i < columns.Length; ++i)
            {
                var width                 = 80;
                var minWidth              = 50;
                var maxWidth              = 1000000f;
                var autoResize            = false;
                var allowToggleVisibility = true;
                switch (columns[i].profilerColumn)
                {
                case HierarchyFrameDataView.columnName:
                    width                 = 200;
                    minWidth              = 200;
                    autoResize            = true;
                    allowToggleVisibility = false;
                    break;

                case HierarchyFrameDataView.columnWarningCount:
                    width    = 25;
                    minWidth = 25;
                    maxWidth = 25;
                    break;
                }

                var headerColumn = new MultiColumnHeaderState.Column
                {
                    headerContent         = columns[i].headerLabel,
                    headerTextAlignment   = TextAlignment.Left,
                    sortingArrowAlignment = TextAlignment.Right,
                    width                 = width,
                    minWidth              = minWidth,
                    maxWidth              = maxWidth,
                    autoResize            = autoResize,
                    allowToggleVisibility = allowToggleVisibility,
                    sortedAscending       = i == 0
                };
                headerColumns[i] = headerColumn;
            }

            var state = new MultiColumnHeaderState(headerColumns)
            {
                sortedColumnIndex = ProfilerFrameDataMultiColumnHeader.GetMultiColumnHeaderIndex(columns, defaultSortColumn),
            };

            return(state);
        }
예제 #6
0
 public static MultiColumnHeaderState CreateDefaultMultiColumnHeaderState(ProfilerFrameDataMultiColumnHeader.Column[] columns, ProfilerColumn defaultSortColumn)
 {
     MultiColumnHeaderState.Column[] array = new MultiColumnHeaderState.Column[columns.Length];
     for (int i = 0; i < columns.Length; i++)
     {
         int            num                   = 80;
         int            num2                  = 50;
         float          maxWidth              = 1000000f;
         bool           autoResize            = false;
         bool           allowToggleVisibility = true;
         ProfilerColumn profilerColumn        = columns[i].profilerColumn;
         if (profilerColumn != ProfilerColumn.FunctionName)
         {
             if (profilerColumn == ProfilerColumn.WarningCount)
             {
                 num      = 25;
                 num2     = 25;
                 maxWidth = 25f;
             }
         }
         else
         {
             num                   = 200;
             num2                  = 200;
             autoResize            = true;
             allowToggleVisibility = false;
         }
         MultiColumnHeaderState.Column column = new MultiColumnHeaderState.Column
         {
             headerContent         = columns[i].headerLabel,
             headerTextAlignment   = TextAlignment.Left,
             sortingArrowAlignment = TextAlignment.Right,
             width                 = (float)num,
             minWidth              = (float)num2,
             maxWidth              = maxWidth,
             autoResize            = autoResize,
             allowToggleVisibility = allowToggleVisibility,
             sortedAscending       = (i == 0)
         };
         array[i] = column;
     }
     return(new MultiColumnHeaderState(array)
     {
         sortedColumnIndex = ProfilerFrameDataMultiColumnHeader.GetMultiColumnHeaderIndex(columns, defaultSortColumn)
     });
 }
예제 #7
0
        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;
        }
        void InitIfNeeded()
        {
            if (m_Initialized)
            {
                return;
            }

            var cpuHierarchyColumns = new[]
            {
                HierarchyFrameDataView.columnName,
                HierarchyFrameDataView.columnTotalPercent,
                HierarchyFrameDataView.columnSelfPercent,
                HierarchyFrameDataView.columnCalls,
                HierarchyFrameDataView.columnGcMemory,
                HierarchyFrameDataView.columnTotalTime,
                HierarchyFrameDataView.columnSelfTime,
                HierarchyFrameDataView.columnWarningCount
            };
            var gpuHierarchyColumns = new[]
            {
                HierarchyFrameDataView.columnName,
                HierarchyFrameDataView.columnTotalGpuPercent,
                HierarchyFrameDataView.columnDrawCalls,
                HierarchyFrameDataView.columnTotalGpuTime
            };
            var profilerColumns   = gpuView ? gpuHierarchyColumns : cpuHierarchyColumns;
            var defaultSortColumn = gpuView ? HierarchyFrameDataView.columnTotalGpuTime : HierarchyFrameDataView.columnTotalTime;

            var columns     = CreateColumns(profilerColumns);
            var headerState = CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            }

            var firstInit = m_MultiColumnHeaderState == null;

            m_MultiColumnHeaderState = headerState;

            var multiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns)
            {
                height = 25
            };

            if (firstInit)
            {
                multiColumnHeader.ResizeToFit();
            }

            // Check if it already exists (deserialized from window layout file or scriptable object)
            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }
            m_TreeView = new ProfilerFrameDataTreeView(m_TreeViewState, multiColumnHeader);
            m_TreeView.selectionChanged += OnMainTreeViewSelectionChanged;
            m_TreeView.searchChanged    += OnMainTreeViewSearchChanged;
            m_TreeView.Reload();

            m_CpuProfilerOptions = SessionState.GetInt(k_CpuProfilerHierarchyViewOptionsPrefKey, m_CpuProfilerOptions);

            m_SearchField = new SearchField();
            m_SearchField.downOrUpArrowKeyPressed += m_TreeView.SetFocusAndEnsureSelectedItem;

            if (m_DetailedObjectsView == null)
            {
                m_DetailedObjectsView = new ProfilerDetailedObjectsView();
            }
            m_DetailedObjectsView.gpuView         = gpuView;
            m_DetailedObjectsView.frameItemEvent += FrameItem;
            if (m_DetailedCallsView == null)
            {
                m_DetailedCallsView = new ProfilerDetailedCallsView();
            }
            m_DetailedCallsView.frameItemEvent += FrameItem;
            if (m_DetailedViewSpliterState == null || m_DetailedViewSpliterState.relativeSizes == null || m_DetailedViewSpliterState.relativeSizes.Length == 0)
            {
                m_DetailedViewSpliterState = new SplitterState(new[] { 70f, 30f }, new[] { 450, 50 }, null);
            }

            m_Initialized = true;
        }
        void InitIfNeeded()
        {
            if (m_Initialized)
            {
                return;
            }

            var cpuHierarchyColumns = new[]
            {
                HierarchyFrameDataView.columnName,
                HierarchyFrameDataView.columnTotalPercent,
                HierarchyFrameDataView.columnSelfPercent,
                HierarchyFrameDataView.columnCalls,
                HierarchyFrameDataView.columnGcMemory,
                HierarchyFrameDataView.columnTotalTime,
                HierarchyFrameDataView.columnSelfTime,
                HierarchyFrameDataView.columnWarningCount
            };
            var gpuHierarchyColumns = new[]
            {
                HierarchyFrameDataView.columnName,
                HierarchyFrameDataView.columnTotalGpuPercent,
                HierarchyFrameDataView.columnDrawCalls,
                HierarchyFrameDataView.columnTotalGpuTime
            };
            var profilerColumns   = gpuView ? gpuHierarchyColumns : cpuHierarchyColumns;
            var defaultSortColumn = gpuView ? HierarchyFrameDataView.columnTotalGpuTime : HierarchyFrameDataView.columnTotalTime;

            var columns = CreateColumns(profilerColumns);

            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
            }
            var headerState = CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            }

            var firstInit = m_MultiColumnHeaderState == null;

            m_MultiColumnHeaderState = headerState;

            var multiColumnHeader = new ProfilerFrameDataMultiColumnHeader(m_MultiColumnHeaderState, columns)
            {
                height = 25
            };

            if (firstInit)
            {
                multiColumnHeader.ResizeToFit();
            }

            multiColumnHeader.visibleColumnsChanged += OnMultiColumnHeaderChanged;
            multiColumnHeader.sortingChanged        += OnMultiColumnHeaderChanged;

            // Check if it already exists (deserialized from window layout file or scriptable object)
            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }
            m_TreeView = new ProfilerFrameDataTreeView(m_TreeViewState, multiColumnHeader, cpuModule);
            m_TreeView.selectionChanged += OnMainTreeViewSelectionChanged;
            m_TreeView.searchChanged    += OnMainTreeViewSearchChanged;
            m_TreeView.Reload();

            m_SearchField = new SearchField();
            m_SearchField.downOrUpArrowKeyPressed += m_TreeView.SetFocusAndEnsureSelectedItem;

            if (m_DetailedObjectsView == null)
            {
                m_DetailedObjectsView = new ProfilerDetailedObjectsView(detailedObjectsViewPrefKeyPrefix);
            }
            m_DetailedObjectsView.gpuView         = gpuView;
            m_DetailedObjectsView.frameItemEvent += FrameItem;
            if (m_DetailedCallsView == null)
            {
                m_DetailedCallsView = new ProfilerDetailedCallsView(detailedCallsViewPrefKeyPrefix);
                m_DetailedCallsView.profilerSampleNameProvider = cpuModule;
            }
            m_DetailedCallsView.frameItemEvent += FrameItem;
            if (m_DetailedViewSpliterState == null || !m_DetailedViewSpliterState.IsValid())
            {
                m_DetailedViewSpliterState = SplitterState.FromRelative(new[] { SessionState.GetFloat(splitter0StatePrefKey, 70f), SessionState.GetFloat(splitter1StatePrefKey, 30f) }, new[] { 450f, 50f }, null);
            }
            if (!m_Serialized)
            {
                m_DetailedViewType = (DetailedViewType)SessionState.GetInt(detailedViewTypeStatePrefKey, (int)DetailedViewType.None);
            }

            m_Serialized  = true;
            m_Initialized = true;
        }
예제 #10
0
 private void InitIfNeeded()
 {
     if (!this.m_Initialized)
     {
         ProfilerColumn[] array = new ProfilerColumn[]
         {
             ProfilerColumn.FunctionName,
             ProfilerColumn.TotalPercent,
             ProfilerColumn.SelfPercent,
             ProfilerColumn.Calls,
             ProfilerColumn.GCMemory,
             ProfilerColumn.TotalTime,
             ProfilerColumn.SelfTime,
             ProfilerColumn.WarningCount
         };
         ProfilerColumn[] array2 = new ProfilerColumn[]
         {
             ProfilerColumn.FunctionName,
             ProfilerColumn.TotalGPUPercent,
             ProfilerColumn.DrawCalls,
             ProfilerColumn.TotalGPUTime
         };
         ProfilerColumn[] profilerColumns   = (!base.gpuView) ? array : array2;
         ProfilerColumn   defaultSortColumn = (!base.gpuView) ? ProfilerColumn.TotalTime : ProfilerColumn.TotalGPUTime;
         ProfilerFrameDataMultiColumnHeader.Column[] columns = ProfilerFrameDataHierarchyView.CreateColumns(profilerColumns);
         MultiColumnHeaderState multiColumnHeaderState       = ProfilerFrameDataHierarchyView.CreateDefaultMultiColumnHeaderState(columns, defaultSortColumn);
         if (MultiColumnHeaderState.CanOverwriteSerializedFields(this.m_MultiColumnHeaderState, multiColumnHeaderState))
         {
             MultiColumnHeaderState.OverwriteSerializedFields(this.m_MultiColumnHeaderState, multiColumnHeaderState);
         }
         bool flag = this.m_MultiColumnHeaderState == null;
         this.m_MultiColumnHeaderState = multiColumnHeaderState;
         ProfilerFrameDataMultiColumnHeader profilerFrameDataMultiColumnHeader = new ProfilerFrameDataMultiColumnHeader(this.m_MultiColumnHeaderState, columns)
         {
             height = 25f
         };
         if (flag)
         {
             profilerFrameDataMultiColumnHeader.ResizeToFit();
         }
         if (this.m_TreeViewState == null)
         {
             this.m_TreeViewState = new TreeViewState();
         }
         this.m_TreeView = new ProfilerFrameDataTreeView(this.m_TreeViewState, profilerFrameDataMultiColumnHeader);
         this.m_TreeView.selectionChanged += new ProfilerFrameDataTreeView.SelectionChangedCallback(this.OnMainTreeViewSelectionChanged);
         this.m_TreeView.searchChanged    += new ProfilerFrameDataTreeView.SearchChangedCallback(this.OnMainTreeViewSearchChanged);
         this.m_SearchField = new SearchField();
         this.m_SearchField.downOrUpArrowKeyPressed += new SearchField.SearchFieldCallback(this.m_TreeView.SetFocusAndEnsureSelectedItem);
         if (this.m_DetailedObjectsView == null)
         {
             this.m_DetailedObjectsView = new ProfilerDetailedObjectsView();
         }
         this.m_DetailedObjectsView.gpuView         = base.gpuView;
         this.m_DetailedObjectsView.frameItemEvent += new ProfilerDetailedObjectsView.FrameItemCallback(this.FrameItem);
         if (this.m_DetailedCallsView == null)
         {
             this.m_DetailedCallsView = new ProfilerDetailedCallsView();
         }
         this.m_DetailedCallsView.frameItemEvent += new ProfilerDetailedCallsView.FrameItemCallback(this.FrameItem);
         if (this.m_DetailedViewSpliterState == null || this.m_DetailedViewSpliterState.relativeSizes == null || this.m_DetailedViewSpliterState.relativeSizes.Length == 0)
         {
             this.m_DetailedViewSpliterState = new SplitterState(new float[]
             {
                 70f,
                 30f
             }, new int[]
             {
                 450,
                 50
             }, null);
         }
         this.m_Initialized = true;
     }
 }