Ejemplo n.º 1
0
        private static void HighlightRowsMatchingObjects(IList <TreeViewItem> rows)
        {
            List <int> list = new List <int>();

            foreach (TreeViewItem current in rows)
            {
                UISystemProfilerTreeView.BatchTreeViewItem batchTreeViewItem = current as UISystemProfilerTreeView.BatchTreeViewItem;
                if (batchTreeViewItem != null)
                {
                    list.AddRange(batchTreeViewItem.instanceIDs);
                }
                else
                {
                    UISystemProfilerTreeView.CanvasTreeViewItem canvasTreeViewItem = current as UISystemProfilerTreeView.CanvasTreeViewItem;
                    if (canvasTreeViewItem != null)
                    {
                        Canvas canvas = EditorUtility.InstanceIDToObject(canvasTreeViewItem.info.objectInstanceId) as Canvas;
                        if (!(canvas == null) && !(canvas.gameObject == null))
                        {
                            list.Add(canvas.gameObject.GetInstanceID());
                        }
                    }
                }
            }
            if (list.Count > 0)
            {
                Selection.instanceIDs = list.ToArray();
            }
        }
Ejemplo n.º 2
0
        internal void DrawRenderUI()
        {
            Rect controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });

            GUI.Box(controlRect, GUIContent.none);
            this.m_ZoomablePreview.BeginViewGUI();
            bool flag = true;

            if (this.m_UGUIProfilerTreeViewState != null && Event.current.type == EventType.Repaint)
            {
                IList <int> selection = this.m_TreeViewControl.GetSelection();
                if (selection.Count > 0)
                {
                    IList <TreeViewItem> rowsFromIDs = this.m_TreeViewControl.GetRowsFromIDs(selection);
                    foreach (TreeViewItem current in rowsFromIDs)
                    {
                        Texture2D texture2D = null;
                        UISystemProfilerTreeView.BatchTreeViewItem batchTreeViewItem = current as UISystemProfilerTreeView.BatchTreeViewItem;
                        UISystemProfiler.Styles.RenderMode         previewRenderMode = UISystemProfiler.PreviewRenderMode;
                        if (this.m_RenderService == null)
                        {
                            this.m_RenderService = new UISystemProfilerRenderService();
                        }
                        if (batchTreeViewItem != null)
                        {
                            texture2D = this.m_RenderService.GetThumbnail(this.currentFrame, batchTreeViewItem.renderDataIndex, 1, previewRenderMode != UISystemProfiler.Styles.RenderMode.Standard);
                        }
                        UISystemProfilerTreeView.CanvasTreeViewItem canvasTreeViewItem = current as UISystemProfilerTreeView.CanvasTreeViewItem;
                        if (canvasTreeViewItem != null)
                        {
                            texture2D = this.m_RenderService.GetThumbnail(this.currentFrame, canvasTreeViewItem.info.renderDataIndex, canvasTreeViewItem.info.renderDataCount, previewRenderMode != UISystemProfiler.Styles.RenderMode.Standard);
                        }
                        if (previewRenderMode == UISystemProfiler.Styles.RenderMode.CompositeOverdraw)
                        {
                            if (this.m_CompositeOverdrawMaterial == null)
                            {
                                Shader shader = Shader.Find("Hidden/UI/CompositeOverdraw");
                                if (shader)
                                {
                                    this.m_CompositeOverdrawMaterial = new Material(shader);
                                }
                            }
                        }
                        if (texture2D)
                        {
                            float num  = (float)texture2D.width;
                            float num2 = (float)texture2D.height;
                            float num3 = Math.Min(controlRect.width / num, controlRect.height / num2);
                            num  *= num3;
                            num2 *= num3;
                            Rect rect = new Rect(controlRect.x + (controlRect.width - num) / 2f, controlRect.y + (controlRect.height - num2) / 2f, num, num2);
                            if (flag)
                            {
                                flag = false;
                                this.m_ZoomablePreview.rect = rect;
                                UISystemProfiler.Styles.PreviewBackgroundType previewBackground = UISystemProfiler.PreviewBackground;
                                if (previewBackground == UISystemProfiler.Styles.PreviewBackgroundType.Checkerboard)
                                {
                                    EditorGUI.DrawTransparencyCheckerTexture(this.m_ZoomablePreview.drawRect, ScaleMode.ScaleAndCrop, 0f);
                                }
                                else
                                {
                                    EditorGUI.DrawRect(this.m_ZoomablePreview.drawRect, (previewBackground != UISystemProfiler.Styles.PreviewBackgroundType.Black) ? Color.white : Color.black);
                                }
                            }
                            Graphics.DrawTexture(this.m_ZoomablePreview.drawRect, texture2D, this.m_ZoomablePreview.shownArea, 0, 0, 0, 0, (previewRenderMode != UISystemProfiler.Styles.RenderMode.CompositeOverdraw) ? EditorGUI.transparentMaterial : this.m_CompositeOverdrawMaterial);
                        }
                        if (previewRenderMode != UISystemProfiler.Styles.RenderMode.Standard)
                        {
                            break;
                        }
                    }
                }
            }
            if (flag && Event.current.type == EventType.Repaint)
            {
                this.m_ZoomablePreview.rect = controlRect;
            }
            this.m_ZoomablePreview.EndViewGUI();
        }
Ejemplo n.º 3
0
        private string GetItemcontent(TreeView.RowGUIArgs args, int column)
        {
            string result;

            if (this.m_AllCanvasesItem != null && args.item.id == this.m_AllCanvasesItem.id)
            {
                switch (column)
                {
                case 2:
                    result = this.m_AllCanvasesItem.totalBatchCount.ToString();
                    return(result);

                case 4:
                    result = this.m_AllCanvasesItem.totalVertexCount.ToString();
                    return(result);

                case 6:
                    result = this.m_AllCanvasesItem.gameObjectCount.ToString();
                    return(result);
                }
                result = null;
            }
            else
            {
                UISystemProfilerTreeView.BatchTreeViewItem batchTreeViewItem = args.item as UISystemProfilerTreeView.BatchTreeViewItem;
                if (batchTreeViewItem != null)
                {
                    UISystemProfilerInfo info = batchTreeViewItem.info;
                    switch (column)
                    {
                    case 0:
                    case 1:
                    case 2:
                        break;

                    case 3:
                        result = info.vertexCount.ToString();
                        return(result);

                    case 4:
                        result = info.totalVertexCount.ToString();
                        return(result);

                    case 5:
                        if (info.batchBreakingReason != BatchBreakingReason.NoBreaking)
                        {
                            result = UISystemProfilerTreeView.FormatBatchBreakingReason(info);
                            return(result);
                        }
                        break;

                    case 6:
                        result = info.instanceIDsCount.ToString();
                        return(result);

                    case 7:
                        if (batchTreeViewItem.instanceIDs.Length <= 5)
                        {
                            StringBuilder stringBuilder = new StringBuilder();
                            for (int i = 0; i < batchTreeViewItem.instanceIDs.Length; i++)
                            {
                                if (i != 0)
                                {
                                    stringBuilder.Append(", ");
                                }
                                int num = batchTreeViewItem.instanceIDs[i];
                                UnityEngine.Object @object = EditorUtility.InstanceIDToObject(num);
                                if (@object == null)
                                {
                                    stringBuilder.Append(num);
                                }
                                else
                                {
                                    stringBuilder.Append(@object.name);
                                }
                            }
                            result = stringBuilder.ToString();
                            return(result);
                        }
                        result = string.Format("{0} objects", batchTreeViewItem.instanceIDs.Length);
                        return(result);

                    case 8:
                        result = info.renderDataIndex.ToString();
                        return(result);

                    default:
                        result = "Missing";
                        return(result);
                    }
                    result = null;
                }
                else
                {
                    UISystemProfilerTreeView.CanvasTreeViewItem canvasTreeViewItem = args.item as UISystemProfilerTreeView.CanvasTreeViewItem;
                    if (canvasTreeViewItem != null)
                    {
                        UISystemProfilerInfo info2 = canvasTreeViewItem.info;
                        switch (column)
                        {
                        case 0:
                        case 3:
                        case 5:
                        case 7:
                            result = null;
                            break;

                        case 1:
                            result = info2.batchCount.ToString();
                            break;

                        case 2:
                            result = info2.totalBatchCount.ToString();
                            break;

                        case 4:
                            result = info2.totalVertexCount.ToString();
                            break;

                        case 6:
                            result = info2.instanceIDsCount.ToString();
                            break;

                        case 8:
                            result = info2.renderDataIndex + " : " + info2.renderDataCount;
                            break;

                        default:
                            result = "Missing";
                            break;
                        }
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        protected override IList <TreeViewItem> BuildRows(TreeViewItem root)
        {
            this.profilerState.lastFrame = this.profilerState.profilerWindow.GetActiveVisibleFrameIndex();
            List <TreeViewItem>  list = new List <TreeViewItem>();
            IList <TreeViewItem> result;

            if (this.property == null || !this.property.frameDataReady)
            {
                result = list;
            }
            else
            {
                this.m_AllCanvasesItem = new UISystemProfilerTreeView.RootTreeViewItem();
                base.SetExpanded(this.m_AllCanvasesItem.id, true);
                root.AddChild(this.m_AllCanvasesItem);
                UISystemProfilerInfo[] uISystemProfilerInfo = this.property.GetUISystemProfilerInfo();
                int[] uISystemBatchInstanceIDs = this.property.GetUISystemBatchInstanceIDs();
                if (uISystemProfilerInfo != null)
                {
                    Dictionary <int, TreeViewItem> dictionary = new Dictionary <int, TreeViewItem>();
                    int num = 0;
                    UISystemProfilerInfo[] array = uISystemProfilerInfo;
                    for (int i = 0; i < array.Length; i++)
                    {
                        UISystemProfilerInfo info = array[i];
                        TreeViewItem         allCanvasesItem;
                        if (!dictionary.TryGetValue(info.parentId, out allCanvasesItem))
                        {
                            allCanvasesItem = this.m_AllCanvasesItem;
                            this.m_AllCanvasesItem.totalBatchCount  += info.totalBatchCount;
                            this.m_AllCanvasesItem.totalVertexCount += info.totalVertexCount;
                            this.m_AllCanvasesItem.gameObjectCount  += info.instanceIDsCount;
                        }
                        UISystemProfilerTreeView.BaseTreeViewItem baseTreeViewItem;
                        if (info.isBatch)
                        {
                            string displayName = "Batch " + num++;
                            baseTreeViewItem = new UISystemProfilerTreeView.BatchTreeViewItem(info, allCanvasesItem.depth + 1, displayName, uISystemBatchInstanceIDs);
                        }
                        else
                        {
                            string displayName = this.property.GetUISystemProfilerNameByOffset(info.objectNameOffset);
                            baseTreeViewItem = new UISystemProfilerTreeView.CanvasTreeViewItem(info, allCanvasesItem.depth + 1, displayName);
                            num = 0;
                            dictionary[info.objectInstanceId] = baseTreeViewItem;
                        }
                        if (!base.IsExpanded(allCanvasesItem.id))
                        {
                            if (!allCanvasesItem.hasChildren)
                            {
                                allCanvasesItem.children = TreeView.CreateChildListForCollapsedParent();
                            }
                        }
                        else
                        {
                            allCanvasesItem.AddChild(baseTreeViewItem);
                        }
                    }
                    this.m_Comparer.Col = UISystemProfilerTreeView.Column.Element;
                    if (base.multiColumnHeader.sortedColumnIndex != -1)
                    {
                        this.m_Comparer.Col = (UISystemProfilerTreeView.Column)base.multiColumnHeader.sortedColumnIndex;
                    }
                    this.m_Comparer.isAscending = base.multiColumnHeader.GetColumn((int)this.m_Comparer.Col).sortedAscending;
                    this.SetupRows(this.m_AllCanvasesItem, list);
                }
                result = list;
            }
            return(result);
        }