예제 #1
0
 public void CurrentAreaChanged(ProfilerArea profilerArea)
 {
     if (profilerArea != ProfilerArea.UI && profilerArea != ProfilerArea.UIDetails)
     {
         if (this.m_DetachedPreview)
         {
             this.m_DetachedPreview.Close();
             this.m_DetachedPreview = null;
         }
         if (this.m_RenderService != null)
         {
             this.m_RenderService.Dispose();
             this.m_RenderService = null;
         }
     }
 }
예제 #2
0
 public void CurrentAreaChanged(ProfilerArea?newArea)
 {
     if (!newArea.HasValue || newArea.Value != ProfilerArea.UI && newArea.Value != ProfilerArea.UIDetails)
     {
         if (m_DetachedPreview)
         {
             m_DetachedPreview.Close();
             m_DetachedPreview = null;
         }
         if (m_RenderService != null)
         {
             m_RenderService.Dispose();
             m_RenderService = null;
         }
     }
 }
예제 #3
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();
        }
        internal void DrawRenderUI()
        {
            var previewRect = EditorGUILayout.GetControlRect(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

            GUI.Box(previewRect, GUIContent.none);
            m_ZoomablePreview.BeginViewGUI();
            bool first = true;

            if (m_UGUIProfilerTreeViewState != null && Event.current.type == EventType.Repaint)
            {
                IList <int> selection = m_TreeViewControl.GetSelection();
                if (selection.Count > 0)
                {
                    IList <TreeViewItem> selectedRows = m_TreeViewControl.GetRowsFromIDs(selection);
                    foreach (TreeViewItem row in selectedRows)
                    {
                        Texture2D image             = null;
                        var       batch             = row as UISystemProfilerTreeView.BatchTreeViewItem;
                        var       previewRenderMode = PreviewRenderMode;
                        if (m_RenderService == null)
                        {
                            m_RenderService = new UISystemProfilerRenderService();
                        }

                        if (batch != null)
                        {
                            image = m_RenderService.GetThumbnail(currentFrame, batch.renderDataIndex, 1, previewRenderMode != Styles.RenderMode.Standard);
                        }
                        var canvas = row as UISystemProfilerTreeView.CanvasTreeViewItem;
                        if (canvas != null)
                        {
                            image = m_RenderService.GetThumbnail(currentFrame, canvas.info.renderDataIndex, canvas.info.renderDataCount,
                                                                 previewRenderMode != Styles.RenderMode.Standard);
                        }

                        if (previewRenderMode == Styles.RenderMode.CompositeOverdraw)
                        {
                            if (m_CompositeOverdrawMaterial == null)
                            {
                                Shader shader = Shader.Find("Hidden/UI/CompositeOverdraw");
                                if (shader)
                                {
                                    m_CompositeOverdrawMaterial = new Material(shader);
                                }
                            }
                        }

                        if (image)
                        {
                            float w           = image.width;
                            float h           = image.height;
                            float scaleFactor = Math.Min(previewRect.width / w, previewRect.height / h);
                            w *= scaleFactor;
                            h *= scaleFactor;
                            var imageRect = new Rect(previewRect.x + (previewRect.width - w) / 2, previewRect.y + (previewRect.height - h) / 2,
                                                     w,
                                                     h);

                            if (first)
                            {
                                first = false;
                                m_ZoomablePreview.rect = imageRect;
                                var previewBackground = PreviewBackground;
                                if (previewBackground == Styles.PreviewBackgroundType.Checkerboard)
                                {
                                    EditorGUI.DrawTransparencyCheckerTexture(m_ZoomablePreview.drawRect, ScaleMode.ScaleAndCrop, 0f);
                                }
                                else
                                {
                                    EditorGUI.DrawRect(m_ZoomablePreview.drawRect,
                                                       previewBackground == Styles.PreviewBackgroundType.Black ? Color.black : Color.white);
                                }
                            }
                            Graphics.DrawTexture(m_ZoomablePreview.drawRect, image, m_ZoomablePreview.shownArea, 0, 0, 0, 0,
                                                 previewRenderMode == Styles.RenderMode.CompositeOverdraw ? m_CompositeOverdrawMaterial : EditorGUI.transparentMaterial);
                        }
                        if (previewRenderMode != Styles.RenderMode.Standard)
                        {
                            break;
                        }
                    }
                }
            }
            if (first && Event.current.type == EventType.Repaint)
            {
                m_ZoomablePreview.rect = previewRect;
            }
            m_ZoomablePreview.EndViewGUI();
        }