Exemple #1
0
        protected override TreeViewItem BuildRoot()
        {
            int idForhiddenRoot                = -1;
            int depthForHiddenRoot             = -1;
            AssetMarkerTreeViewItem root       = new AssetMarkerTreeViewItem(idForhiddenRoot, depthForHiddenRoot, "root", null);
            AssetLoadingFrameSetup  frameSetup = m_ProfilerView.GetFrameSetup();
            int  currentFrame = m_ProfilerView.GetSelectedFrame();
            bool singleFrame  = frameSetup == AssetLoadingFrameSetup.ThisFrame;

            var data = m_CaptureData.m_AssetLoadMarkers.OrderBy(s => s.startNs).ToList();

            // reset the states
            foreach (var item in data)
            {
                item.addedToTreeView = false;
            }

            for (int index = 0, id = 0; index < data.Count; ++index)
            {
                CreateAndAddChild(data, root, currentFrame, singleFrame, ref index, ref id);
            }

            // Return root of the tree
            SetupDepthsFromParentsAndChildren(root);
            return(root);
        }
Exemple #2
0
 void AddAllChildren(IList <TreeViewItem> rows, AssetMarkerTreeViewItem node)
 {
     rows.Add(node);
     if (!node.hasChildren || !IsExpanded(node.id))
     {
         return;
     }
     SortByMultipleColumns(node);
     foreach (AssetMarkerTreeViewItem child in node.children)
     {
         AddAllChildren(rows, child);
     }
 }
Exemple #3
0
 private void CellLabel(Rect cellRect, AssetMarkerTreeViewItem item, GUIContent content)
 {
     EditorGUI.LabelField(cellRect, content);
 }
Exemple #4
0
        void CellGUI(Rect cellRect, AssetMarkerTreeViewItem item, Columns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            switch (column)
            {
            case Columns.Index:
                int id = item.assetLoadingMarker.index > 0 ? item.assetLoadingMarker.index + 1 : item.id + 1;
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", id)));
                break;

            case Columns.Source:
            {
                var indentX = GetContentIndent(item);
                cellRect.x     += indentX;
                cellRect.width -= indentX;

                string prefix = GetSourcePrefix(item.assetLoadingMarker.type);

                if (string.IsNullOrEmpty(item.assetLoadingMarker.sourceName))
                {
                    CellLabel(cellRect, item, new GUIContent($"{prefix}{item.assetLoadingMarker.readableFileName}", item.assetLoadingMarker.readablePath));
                }
                else
                {
                    CellLabel(cellRect, item, new GUIContent($"{prefix}{item.assetLoadingMarker.sourceName}", item.assetLoadingMarker.readablePath));
                }
                break;
            }

            case Columns.AssetName:
                CellLabel(cellRect, item, new GUIContent(item.assetLoadingMarker.assetName));
                break;

            case Columns.ThreadName:
                CellLabel(cellRect, item, new GUIContent(item.assetLoadingMarker.threadName));
                break;

            case Columns.Type:
                CellLabel(cellRect, item, new GUIContent(item.assetLoadingMarker.subsystem));
                break;

            case Columns.SizeBytes:
            {
                if (item.assetLoadingMarker.sizeBytes == 0)
                {
                    CellLabel(cellRect, item, new GUIContent("Unknown size"));
                }
                else
                {
                    CellLabel(cellRect, item, new GUIContent(string.Format("{0}", EditorUtility.FormatBytes((int)item.assetLoadingMarker.sizeBytes)), string.Format("{0} B", item.assetLoadingMarker.sizeBytes)));
                }
                break;
            }

            case Columns.MarkerType:
                CellLabel(cellRect, item, new GUIContent(item.assetLoadingMarker.type.ToString()));
                break;

            case Columns.Timestamp:
            {
                var    ts   = TimeSpan.FromMilliseconds(item.assetLoadingMarker.startTimeMs);
                string time = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D4}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                CellLabel(cellRect, item, new GUIContent(time, string.Format("{0}ms", item.assetLoadingMarker.startTimeMs)));
                break;
            }

            case Columns.MarkerTimeMs:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0:f2}", item.assetLoadingMarker.ms)));
                break;

            case Columns.FirstFrameIndex:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", item.assetLoadingMarker.firstFrameIndex)));
                break;

            case Columns.LastFrameIndex:
                CellLabel(cellRect, item, new GUIContent(string.Format("{0}", item.assetLoadingMarker.lastFrameIndex)));
                break;

            case Columns.FrameCount:
            {
                string label;
                if (m_ProfilerView.GetFrameSetup() == AssetLoadingFrameSetup.ThisFrame)
                {
                    int selectedFrame          = m_ProfilerView.GetSelectedFrame(); // will the range of the profiler frames always match up with the item.fileAccessMarker.frameIndexes?
                    int framesSinceAccessStart = (selectedFrame - item.assetLoadingMarker.firstFrameIndex) + 1;
                    label = $"{framesSinceAccessStart}/{item.assetLoadingMarker.frameCount}";
                }
                else
                {
                    label = item.assetLoadingMarker.frameCount.ToString();
                }

                CellLabel(cellRect, item, new GUIContent(label));
                break;
            }
            }

            ShowContextMenu(cellRect, item.assetLoadingMarker);
        }
Exemple #5
0
        protected void CreateAndAddChild(List <AssetLoadMarker> data, AssetMarkerTreeViewItem parent, int currentFrame, bool singleFrame, ref int index, ref int id)
        {
            if (data[index].addedToTreeView)
            {
                return;
            }

            var assetLoadMarker = data[index];

            if (!m_ProfilerView.FilterContains(assetLoadMarker.sourceName) && !m_ProfilerView.FilterContains(assetLoadMarker.assetName))
            {
                return;
            }

            if (singleFrame)
            {
                if (currentFrame < assetLoadMarker.firstFrameIndex || currentFrame > assetLoadMarker.lastFrameIndex)
                {
                    return;
                }
            }

            if (!m_ProfilerView.FilterActive())
            {
                assetLoadMarker.index = id;
            }

            var item = new AssetMarkerTreeViewItem(id, 0, assetLoadMarker.sourceName, assetLoadMarker);

            parent.AddChild(item);
            id++;
            m_Count++;
            data[index].addedToTreeView = true; // Avoid duplicates

            if (index + 1 >= data.Count)
            {
                return;
            }

            var nextMarker = data[index + 1];
            int lastIndex  = index; // Record where to come back to when done checking for children

            // As markers are ordered by start time, only need to check until we find one that starts after this one has finished
            while (nextMarker.startNs < assetLoadMarker.endNs)
            {
                index++;

                if (!nextMarker.addedToTreeView && nextMarker.endNs <= assetLoadMarker.endNs && nextMarker.depth > assetLoadMarker.depth && nextMarker.threadIndex == assetLoadMarker.threadIndex)
                {
                    CreateAndAddChild(data, item, currentFrame, singleFrame, ref index, ref id);
                }

                if (index + 1 >= data.Count)
                {
                    break;
                }
                nextMarker = data[index + 1];
            }

            index = lastIndex;
        }