Ejemplo n.º 1
0
        private void DrawColumnsHeader(string searchString)
        {
            bool flag = false;

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
            {
                flag = true;
                Event.current.type = EventType.Used;
            }
            SplitterGUILayout.BeginHorizontalSplit(this.m_Splitter, GUIStyle.none, new GUILayoutOption[0]);
            this.DrawTitle((!this.IsSearchActive()) ? this.m_HeaderContent[0] : this.m_SearchHeader, 0);
            for (int i = 1; i < this.m_ColumnNames.Length; i++)
            {
                this.DrawTitle(this.m_HeaderContent[i], i);
            }
            SplitterGUILayout.EndHorizontalSplit();
            GUILayout.EndHorizontal();
            if (flag)
            {
                Event.current.type = EventType.MouseDown;
                this.HandleHeaderMouse(GUILayoutUtility.GetLastRect());
            }
            GUILayout.Space(1f);
        }
Ejemplo n.º 2
0
        //============================================================================================================//
        // OnGUI
        //============================================================================================================//
        public void OnGUI()
        {
            if (!ErrorTestsPass())
            {
                return;
            }

            //Get any updates since the last frame.
            m_so.Update();

            CheckForEditorVarsChanges();

            DrawToolbar();
            GUILayout.BeginVertical();
            DrawTitle();

            SplitterGUILayout.BeginHorizontalSplit(m_splitterState);
            DrawLeftPanel();
            DrawRightPanel();
            SplitterGUILayout.EndHorizontalSplit();

            GUILayout.EndVertical();

            //Save all changes made this frame.
            m_so.ApplyModifiedProperties();
        }
Ejemplo n.º 3
0
        void DrawDetailedMemoryPane(SplitterState splitter)
        {
            SplitterGUILayout.BeginHorizontalSplit(splitter);

            m_MemoryListView.OnGUI();
            m_ReferenceListView.OnGUI();

            SplitterGUILayout.EndHorizontalSplit();
        }
Ejemplo n.º 4
0
        void DoUpdateReportArea(
            UpdateReportListView updateReportListView,
            object splitterState)
        {
            SplitterGUILayout.BeginHorizontalSplit(splitterState);

            DoUpdateReportViewArea(updateReportListView);

            DoErrorDetailsTextArea(updateReportListView.GetSelectedError());

            SplitterGUILayout.EndHorizontalSplit();
        }
Ejemplo n.º 5
0
        public void DoGUI(FrameDataView frameDataView)
        {
            this.InitIfNeeded();
            bool flag = frameDataView != null && frameDataView.IsValid();

            this.m_TreeView.SetFrameDataView(frameDataView);
            bool flag2 = flag && this.m_DetailedViewType != ProfilerFrameDataHierarchyView.DetailedViewType.None;

            if (flag2)
            {
                SplitterGUILayout.BeginHorizontalSplit(this.m_DetailedViewSpliterState, new GUILayoutOption[0]);
            }
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            this.DrawToolbar(frameDataView, flag2);
            if (!flag)
            {
                GUILayout.Label(ProfilerFrameDataViewBase.BaseStyles.noData, ProfilerFrameDataViewBase.BaseStyles.label, new GUILayoutOption[0]);
            }
            else
            {
                Rect rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, new GUILayoutOption[]
                {
                    GUILayout.ExpandHeight(true),
                    GUILayout.ExpandHeight(true)
                });
                this.m_TreeView.OnGUI(rect);
            }
            GUILayout.EndVertical();
            if (flag2)
            {
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                EditorGUILayout.BeginHorizontal(ProfilerFrameDataViewBase.BaseStyles.toolbar, new GUILayoutOption[0]);
                this.DrawDetailedViewPopup();
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                ProfilerFrameDataHierarchyView.DetailedViewType detailedViewType = this.m_DetailedViewType;
                if (detailedViewType != ProfilerFrameDataHierarchyView.DetailedViewType.Objects)
                {
                    if (detailedViewType == ProfilerFrameDataHierarchyView.DetailedViewType.CallersAndCallees)
                    {
                        this.detailedCallsView.DoGUI(ProfilerFrameDataViewBase.BaseStyles.header, frameDataView, this.m_TreeView.GetSelection());
                    }
                }
                else
                {
                    this.detailedObjectsView.DoGUI(ProfilerFrameDataViewBase.BaseStyles.header, frameDataView, this.m_TreeView.GetSelection());
                }
                GUILayout.EndVertical();
                SplitterGUILayout.EndHorizontalSplit();
            }
            this.HandleKeyboardEvents();
        }
Ejemplo n.º 6
0
        void DoListArea(
            UpdateReportListView errorsListView,
            object splitterState)
        {
            EditorGUILayout.BeginVertical();
            SplitterGUILayout.BeginHorizontalSplit(splitterState);

            DoErrorsListViewArea(errorsListView);
            DoErrorDetailsTextArea(errorsListView.GetSelectedError());

            SplitterGUILayout.EndHorizontalSplit();
            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 7
0
        public void OnGUI()
        {
            // Make sure that editor options are synchronized
            BurstEditorOptions.EnsureSynchronized();

            if (_targets == null)
            {
                _targets = BurstReflection.FindExecuteMethods(AssembliesType.Editor);
                foreach (var target in _targets)
                {
                    // Enable burst compilation by default (override globals for the inspector)
                    // This is not working as expected. This changes indirectly the global options while it shouldn't
                    // Unable to explain how it can happen
                    // so for now, if global enable burst compilation is disabled, then inspector is too
                    //target.Options.EnableBurstCompilation = true;
                }

                // Order targets per name
                _targets.Sort((left, right) => string.Compare(left.GetDisplayName(), right.GetDisplayName(), StringComparison.Ordinal));

                _treeView.Targets = _targets;
                _treeView.Reload();

                if (_selectedItem != null)
                {
                    _treeView.TrySelectByDisplayName(_selectedItem);
                }
            }

            if (_fontSizesText == null)
            {
                _fontSizesText = new string[FontSizes.Length];
                for (var i = 0; i < FontSizes.Length; ++i)
                {
                    _fontSizesText[i] = FontSizes[i].ToString();
                }
            }

            if (_fontSizeIndex == -1)
            {
                _fontSizeIndex = EditorPrefs.GetInt(FontSizeIndexPref, 5);
                _fontSizeIndex = Math.Max(0, _fontSizeIndex);
                _fontSizeIndex = Math.Min(_fontSizeIndex, FontSizes.Length - 1);
            }

            if (_fixedFontStyle == null)
            {
                _fixedFontStyle = new GUIStyle(GUI.skin.label);
                string fontName;
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    fontName = "Consolas";
                }
                else
                {
                    fontName = "Courier";
                }

                CleanupFont();

                _font = Font.CreateDynamicFontFromOSFont(fontName, FontSize);
                _fixedFontStyle.font     = _font;
                _fixedFontStyle.fontSize = FontSize;
            }

            if (_searchField == null)
            {
                _searchField = new SearchField();
            }

            if (_textArea == null)
            {
                _textArea = new LongTextArea();
            }

            GUILayout.BeginHorizontal();

            // SplitterGUILayout.BeginHorizontalSplit is internal in Unity but we don't have much choice
            SplitterGUILayout.BeginHorizontalSplit(TreeViewSplitterState);

            GUILayout.BeginVertical(GUILayout.Width(position.width / 3));

            GUILayout.Label("Compile Targets", EditorStyles.boldLabel);

            var newFilter = _searchField.OnGUI(_treeView.Filter);

            if (newFilter != _treeView.Filter)
            {
                _treeView.Filter = newFilter;
                _treeView.Reload();
            }

            _treeView.OnGUI(GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)));

            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            var selection = _treeView.GetSelection();

            if (selection.Count == 1)
            {
                var targetIndex   = selection[0];
                var target        = _targets[targetIndex - 1];
                var targetOptions = target.Options;

                // Stash selected item name to handle domain reloads more gracefully
                _selectedItem = target.GetDisplayName();

                // Refresh if any options are changed
                bool doCopy;
                int  fontSize;
                // -14 to add a little bit of space for the vertical scrollbar to display correctly
                RenderButtonBars((position.width * 2) / 3 - 14, target, out doCopy, out fontSize);

                // We are currently formatting only Asm output
                var isTextFormatted = _enhancedDisassembly && _disasmKind == DisassemblyKind.Asm;

                // Depending if we are formatted or not, we don't render the same text
                var textToRender = isTextFormatted ? target.FormattedDisassembly : target.RawDisassembly;

                // Only refresh if we are switching to a new selection that hasn't been disassembled yet
                // Or we are changing disassembly settings (safety checks / enhanced disassembly)
                var targetRefresh = textToRender == null ||
                                    target.DisassemblyKind != _disasmKind ||
                                    targetOptions.EnableBurstSafetyChecks != _safetyChecks ||
                                    target.TargetCpu != _targetCpu ||
                                    target.IsDarkMode != EditorGUIUtility.isProSkin;

                bool targetChanged = _previousTargetIndex != targetIndex;

                _previousTargetIndex = targetIndex;

                if (targetRefresh)
                {
                    // TODO: refactor this code with a proper AppendOption to avoid these "\n"
                    var options = new StringBuilder();

                    target.TargetCpu       = _targetCpu;
                    target.DisassemblyKind = _disasmKind;
                    targetOptions.EnableBurstSafetyChecks = _safetyChecks;
                    target.IsDarkMode = EditorGUIUtility.isProSkin;
                    targetOptions.EnableBurstCompileSynchronously = true;

                    string defaultOptions;
                    if (targetOptions.TryGetOptions(target.IsStaticMethod ? (MemberInfo)target.Method : target.JobType, true, out defaultOptions))
                    {
                        options.Append(defaultOptions);

                        options.AppendFormat("\n" + BurstCompilerOptions.GetOption(BurstCompilerOptions.OptionTarget, TargetCpuNames[(int)_targetCpu]));

                        options.AppendFormat("\n" + BurstCompilerOptions.GetOption(BurstCompilerOptions.OptionDebug));

                        var baseOptions = options.ToString().Trim('\n', ' ');

                        target.RawDisassembly = GetDisassembly(target.Method, baseOptions + DisasmOptions[(int)_disasmKind]);

                        if (isTextFormatted)
                        {
                            // Store the formatted version
                            target.FormattedDisassembly = _burstDisassembler.Process(target.RawDisassembly, IsIntel(_targetCpu) ? BurstDisassembler.AsmKind.Intel : BurstDisassembler.AsmKind.ARM, target.IsDarkMode);
                            textToRender = target.FormattedDisassembly;
                        }
                        else
                        {
                            target.FormattedDisassembly = null;
                            textToRender = target.RawDisassembly;
                        }
                    }
                }

                if (textToRender != null)
                {
                    _textArea.Text = textToRender;
                    if (targetChanged)
                    {
                        _scrollPos = Vector2.zero;
                    }
                    _scrollPos = GUILayout.BeginScrollView(_scrollPos, true, true);
                    _textArea.Render(_fixedFontStyle);
                    GUILayout.EndScrollView();
                }

                if (doCopy)
                {
                    // When copying to the clipboard, we copy the non-formatted version
                    EditorGUIUtility.systemCopyBuffer = target.RawDisassembly ?? string.Empty;
                }

                if (fontSize != _fontSizeIndex)
                {
                    _fontSizeIndex = fontSize;
                    EditorPrefs.SetInt(FontSizeIndexPref, fontSize);
                    _fixedFontStyle = null;
                }
            }

            GUILayout.EndVertical();

            SplitterGUILayout.EndHorizontalSplit();

            GUILayout.EndHorizontal();
        }
        public void DoGUI(HierarchyFrameDataView frameDataView)
        {
            using (m_DoGUIMarker.Auto())
            {
                InitIfNeeded();

                var collectingSamples = ProfilerDriver.enabled && (ProfilerDriver.profileEditor || EditorApplication.isPlaying);
                var isSearchAllowed   = string.IsNullOrEmpty(treeView.searchString) || !(collectingSamples && ProfilerDriver.deepProfiling);

                var isDataAvailable = frameDataView != null && frameDataView.valid;

                var showDetailedView = isDataAvailable && m_DetailedViewType != DetailedViewType.None;
                if (showDetailedView)
                {
                    SplitterGUILayout.BeginHorizontalSplit(m_DetailedViewSpliterState);
                }

                // Hierarchy view area
                GUILayout.BeginVertical();

                DrawToolbar(frameDataView, showDetailedView);

                if (!isDataAvailable)
                {
                    GUILayout.Label(BaseStyles.noData, BaseStyles.label);
                }
                else if (!isSearchAllowed)
                {
                    GUILayout.Label(BaseStyles.disabledSearchText, BaseStyles.label);
                }
                else
                {
                    var rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandHeight(true));
                    m_TreeView.SetFrameDataView(frameDataView);
                    m_TreeView.OnGUI(rect);
                }

                GUILayout.EndVertical();

                if (showDetailedView)
                {
                    GUILayout.BeginVertical();

                    // Detailed view area
                    EditorGUILayout.BeginHorizontal(BaseStyles.toolbar);

                    DrawDetailedViewPopup();
                    GUILayout.FlexibleSpace();

                    DrawOptionsMenuPopup();
                    EditorGUILayout.EndHorizontal();

                    switch (m_DetailedViewType)
                    {
                    case DetailedViewType.Objects:
                        detailedObjectsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                        break;

                    case DetailedViewType.CallersAndCallees:
                        detailedCallsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                        break;
                    }

                    GUILayout.EndVertical();

                    SplitterGUILayout.EndHorizontalSplit();
                }

                HandleKeyboardEvents();
            }
        }
    private void OnGUI()
    {
        if (m_assets == null)
        {
            if (GUILayout.Button("Load Data"))
            {
                EditorUtility.DisplayProgressBar("Loading", "Please Wait", 0f);

                CalculateAssetsAndBundles();
                LoadAssetSizes();
                CalculateReferencedBundles();
                UpdateAssetSizeRecursive();

                m_mainPaneMode = HierarchyMode.Recurse;
                UpdateAssetsOrdered(m_mainPaneMode);

                CalculateBundleSize();
                CalculateTotalBundleSize();
                CalculateTotalAssetSize();

                BuildGroupSizes();

                EditorUtility.ClearProgressBar();

                m_columnHeaderStyle           = new GUIStyle("dockArea");
                m_columnHeaderStyle.alignment = TextAnchor.MiddleLeft;
                m_columnHeaderStyle.padding   = new RectOffset(10, 0, 0, 0);
                m_columnHeaderStyle.fontStyle = FontStyle.Bold;

                m_foldoutStyle = new GUIStyle("IN Foldout");
            }
        }
        else
        {
            Toolbar();

            SplitterGUILayout.BeginVerticalSplit(m_mainVerticalSplit);
            {
                SplitterGUILayout.BeginHorizontalSplit(m_upperHorizontalSplit);
                {
                    EditorGUILayout.BeginVertical("box");
                    {
                        GroupPane();
                    }
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical("box");
                    {
                        AssetListPane();
                    }
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginHorizontal();
                    {
                        if (!m_selected.Any())
                        {
                            EditorGUILayout.BeginVertical("box");
                            {
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.FlexibleSpace();
                                }
                                GUILayout.EndHorizontal();
                                GUILayout.FlexibleSpace();
                            }
                            EditorGUILayout.EndVertical();
                        }
                        else
                        {
                            SplitterGUILayout.BeginVerticalSplit(m_depVerticalSplit);
                            {
                                EditorGUILayout.BeginVertical("box");
                                {
                                    ReverseDepTree();
                                }
                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical("box");
                                {
                                    SelectedDeps();
                                }
                                EditorGUILayout.EndVertical();

                                EditorGUILayout.BeginVertical("box");
                                {
                                    SelectedReferencedBundles();
                                }
                                EditorGUILayout.EndVertical();
                            }
                            SplitterGUILayout.EndVerticalSplit();
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                SplitterGUILayout.EndHorizontalSplit();

                SplitterGUILayout.BeginHorizontalSplit(m_lowerHorizontalSplit);
                {
                    EditorGUILayout.BeginVertical("box");
                    {
                        BundlePane();
                    }
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical("box");
                    {
                        AssetPane();
                    }
                    EditorGUILayout.EndVertical();
                }
                SplitterGUILayout.EndHorizontalSplit();
            }
            SplitterGUILayout.EndVerticalSplit();

            DisplayBottomBar();
        }
    }
Ejemplo n.º 10
0
        public void OnGUI()
        {
            if (m_ScheduledWindowPicking)
            {
                if (m_PickingData.TrySelectWindow(m_ScheduledWindowPicking))
                {
                    EndPicking(m_PickingData.Selected);
                    m_VisualTreeTreeView.ExpandAll();
                }
                m_ScheduledWindowPicking = null;
            }
            else if (m_ScheduleRestoreSelection)
            {
                m_ScheduleRestoreSelection = false;
                if (m_PickingData.TryRestoreSelectedWindow(m_LastWindowTitle))
                {
                    EndPicking(m_PickingData.Selected);
                    m_VisualTreeTreeView.ExpandAll();
                }
                else
                {
                    m_LastWindowTitle = String.Empty;
                }
            }

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            bool refresh = false;

            EditorGUI.BeginChangeCheck();

            m_PickingData.DoSelectDropDown(() => { m_Refresh = true; });

            bool includeShadowHierarchy = GUILayout.Toggle(m_VisualTreeTreeView.includeShadowHierarchy, Styles.includeShadowHierarchyContent, EditorStyles.toolbarButton);

            if (includeShadowHierarchy != m_VisualTreeTreeView.includeShadowHierarchy)
            {
                m_VisualTreeTreeView.includeShadowHierarchy = includeShadowHierarchy;
                refresh = true;
            }

            GUI.enabled = m_CurPanel.HasValue;
            using (var changedScope = new EditorGUI.ChangeCheckScope())
            {
                m_PickingElementInPanel = GUILayout.Toggle(m_PickingElementInPanel, Styles.pickElementInPanelContent, EditorStyles.toolbarButton);
                if (changedScope.changed && m_PickingElementInPanel)
                {
                    m_CurPanel?.View.Focus();
                }
            }
            GUI.enabled = true;

            bool overlay = GUILayout.Toggle(m_Overlay, Styles.overlayContent, EditorStyles.toolbarButton);

            if (!overlay && !m_PickingElementInPanel)
            {
                panelDebug?.SetHighlightElement(null);
            }

            // Refresh overlay
            if (m_Overlay != overlay)
            {
                m_Overlay = overlay;
                m_CurPanel?.Panel.visualTree.MarkDirtyRepaint();
            }

            // Note for future us : the UXML reload feature isn't quite ready to be public
            if (Unsupported.IsDeveloperBuild())
            {
                bool uxmlLiveReloadIsEnabled    = RetainedMode.UxmlLiveReloadIsEnabled;
                bool newUxmlLiveReloadIsEnabled = GUILayout.Toggle(uxmlLiveReloadIsEnabled, Styles.liveReloadContent, EditorStyles.toolbarButton);
                if (newUxmlLiveReloadIsEnabled != uxmlLiveReloadIsEnabled)
                {
                    RetainedMode.UxmlLiveReloadIsEnabled = newUxmlLiveReloadIsEnabled;
                }
            }

            EditorGUILayout.EndHorizontal();
            if (refresh || m_Refresh)
            {
                Refresh();
                m_Refresh = false;
            }

            if (m_CurPanel.HasValue)
            {
                SplitterGUILayout.BeginHorizontalSplit(m_SplitterState, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                SplitterGUILayout.EndHorizontalSplit();

                float bottomBarHeight = EditorGUI.kSingleLineHeight + Styles.SearchFieldPaddingTop + Styles.SearchFieldPaddingBottom;
                float column1Width    = m_SplitterState.realSizes.Length > 0 ? m_SplitterState.realSizes[0] : 150;
                float column2Width    = position.width - column1Width;
                float column1Height   = position.height - EditorGUI.kWindowToolbarHeight - bottomBarHeight;
                float column2Height   = position.height - EditorGUI.kWindowToolbarHeight;

                Rect column1Rect   = new Rect(0, EditorGUI.kWindowToolbarHeight, column1Width, column1Height);
                Rect column2Rect   = new Rect(column1Width, EditorGUI.kWindowToolbarHeight, column2Width, column2Height);
                Rect bottomBarRect = new Rect(0, column1Rect.yMax, column1Rect.xMax, bottomBarHeight);

                GUI.Label(bottomBarRect, GUIContent.none, Styles.KBottomBarBg);

                float  searchFieldWidth = column1Rect.xMax - Styles.SearchFieldPaddingLeft - Styles.SearchFieldPaddingRight;
                Rect   searchFieldRect  = new Rect(Styles.SearchFieldPaddingLeft, column1Rect.yMax + Styles.SearchFieldPaddingTop, searchFieldWidth, EditorGUI.kSingleLineHeight);
                string searchFilter     = EditorGUI.ToolbarSearchField(searchFieldRect, m_SearchFieldText, false);

                if (searchFilter != m_SearchFieldText)
                {
                    m_SearchFieldText = searchFilter;
                    m_VisualTreeTreeView.searchString = searchFilter;
                }

                m_VisualTreeTreeView.OnGUI(column1Rect);

                DrawSelection(column2Rect);

                // Draw separator
                EditorGUI.DrawRect(
                    new Rect(column1Width + column1Rect.xMin, column1Rect.y, 1, column1Rect.height + bottomBarHeight),
                    Styles.separatorColor);
            }
        }
Ejemplo n.º 11
0
        public void OnGUI()
        {
            if (m_ScheduledWindowPicking)
            {
                if (m_PickingData.TrySelectWindow(m_ScheduledWindowPicking))
                {
                    EndPicking(m_PickingData.Selected);
                    m_VisualTreeTreeView.ExpandAll();
                }
                m_ScheduledWindowPicking = null;
            }
            else if (m_ScheduleRestoreSelection)
            {
                m_ScheduleRestoreSelection = false;
                if (m_PickingData.TryRestoreSelectedWindow(m_LastWindowTitle))
                {
                    EndPicking(m_PickingData.Selected);
                    m_VisualTreeTreeView.ExpandAll();
                }
                else
                {
                    m_LastWindowTitle = String.Empty;
                }
            }

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            bool refresh = false;

            EditorGUI.BeginChangeCheck();
            m_PickingData.DoSelectDropDown(() =>
                                           { Dictionary <int, Panel> .Enumerator it = UIElementsUtility.GetPanelsIterator();
                                             while (it.MoveNext())
                                             {
                                                 it.Current.Value.panelDebug = null;
                                             }
                                             m_Refresh = true; });

            bool includeShadowHierarchy = GUILayout.Toggle(m_VisualTreeTreeView.includeShadowHierarchy, Styles.includeShadowHierarchyContent, EditorStyles.toolbarButton);

            if (includeShadowHierarchy != m_VisualTreeTreeView.includeShadowHierarchy)
            {
                m_VisualTreeTreeView.includeShadowHierarchy = includeShadowHierarchy;
                refresh = true;
            }

            GUI.enabled = m_CurPanel.HasValue;
            bool newPickingElementInPanel = GUILayout.Toggle(m_PickingElementInPanel, Styles.pickElementInPanelContent, EditorStyles.toolbarButton);

            m_PickingElementInPanel = newPickingElementInPanel;
            GUI.enabled             = true;

            m_Overlay = GUILayout.Toggle(m_Overlay, Styles.overlayContent, EditorStyles.toolbarButton);

            // Note for future us : the UXML reload feature isn't quite ready to be public
            if (Unsupported.IsDeveloperBuild())
            {
                bool uxmlLiveReloadIsEnabled    = RetainedMode.UxmlLiveReloadIsEnabled;
                bool newUxmlLiveReloadIsEnabled = GUILayout.Toggle(uxmlLiveReloadIsEnabled, Styles.liveReloadContent, EditorStyles.toolbarButton);
                if (newUxmlLiveReloadIsEnabled != uxmlLiveReloadIsEnabled)
                {
                    RetainedMode.UxmlLiveReloadIsEnabled = newUxmlLiveReloadIsEnabled;
                }
            }

            EditorGUILayout.EndHorizontal();

            if (refresh || m_Refresh)
            {
                EndPicking(m_PickingData.Selected);
            }

            if (m_CurPanel.HasValue)
            {
                if (m_CurPanel.Value.Panel.panelDebug.enabled != (m_Overlay || m_PickingElementInPanel))
                {
                    m_CurPanel.Value.Panel.panelDebug.enabled = m_Overlay || m_PickingElementInPanel;
                    m_CurPanel.Value.Panel.visualTree.Dirty(ChangeType.Repaint);
                }

                SplitterGUILayout.BeginHorizontalSplit(m_SplitterState, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                SplitterGUILayout.EndHorizontalSplit();

                float column1Width = m_SplitterState.realSizes.Length > 0 ? m_SplitterState.realSizes[0] : 150;
                float column2Width = position.width - column1Width;
                Rect  column1Rect  = new Rect(0, EditorGUI.kWindowToolbarHeight, column1Width, position.height - EditorGUI.kWindowToolbarHeight);
                Rect  column2Rect  = new Rect(column1Width, EditorGUI.kWindowToolbarHeight, column2Width, column1Rect.height);

                m_VisualTreeTreeView.OnGUI(column1Rect);
                DrawSelection(column2Rect);

                // Draw separator
                EditorGUI.DrawRect(
                    new Rect(column1Width + column1Rect.xMin, column1Rect.y, 1, column1Rect.height),
                    Styles.separatorColor);
            }
        }
Ejemplo n.º 12
0
 public static void BeginHorizontalSplit(SplitterState state, params GUILayoutOption[] options)
 => SplitterGUILayout.BeginHorizontalSplit(state.state, options);
        public void DoGUI(FrameDataView frameDataView)
        {
            InitIfNeeded();

            var isDataAvailable = frameDataView != null && frameDataView.IsValid();

            m_TreeView.SetFrameDataView(frameDataView);

            var showDetailedView = isDataAvailable && m_DetailedViewType != DetailedViewType.None;

            if (showDetailedView)
            {
                SplitterGUILayout.BeginHorizontalSplit(m_DetailedViewSpliterState);
            }

            // Hierarchy view area
            GUILayout.BeginVertical();

            DrawToolbar(frameDataView, showDetailedView);

            if (!isDataAvailable)
            {
                GUILayout.Label(BaseStyles.noData, BaseStyles.label);
            }
            else
            {
                var rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandHeight(true));
                m_TreeView.OnGUI(rect);
            }

            GUILayout.EndVertical();

            if (showDetailedView)
            {
                GUILayout.BeginVertical();

                // Detailed view area
                EditorGUILayout.BeginHorizontal(BaseStyles.toolbar);

                DrawDetailedViewPopup();
                GUILayout.FlexibleSpace();

                EditorGUILayout.EndHorizontal();

                switch (m_DetailedViewType)
                {
                case DetailedViewType.Objects:
                    detailedObjectsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                    break;

                case DetailedViewType.CallersAndCallees:
                    detailedCallsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                    break;
                }

                GUILayout.EndVertical();

                SplitterGUILayout.EndHorizontalSplit();
            }

            HandleKeyboardEvents();
        }
Ejemplo n.º 14
0
        void DrawNetworkOperationsPane(Rect position)
        {
            SplitterGUILayout.BeginHorizontalSplit(m_NetworkSplit);
            var overviewLabel = GUIContent.Temp(ProfilerDriver.GetOverviewText(ProfilerArea.NetworkOperations,
                                                                               m_ProfilerWindow.GetActiveVisibleFrameIndex()));
            var labelRect = GUILayoutUtility.GetRect(overviewLabel, EditorStyles.wordWrappedLabel);

            GUI.Label(labelRect, overviewLabel, EditorStyles.wordWrappedLabel);

            m_PaneScroll = GUILayout.BeginScrollView(m_PaneScroll, ProfilerWindow.Styles.background);

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            EditorGUILayout.LabelField("Operation Detail");
            EditorGUILayout.LabelField("Over 5 Ticks");
            EditorGUILayout.LabelField("Over 10 Ticks");
            EditorGUILayout.LabelField("Total");
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel += 1;

            for (short msgId = 0; msgId < msgNames.Length; msgId++)
            {
#pragma warning disable CS0618
                if (!NetworkDetailStats.m_NetworkOperations.ContainsKey(msgId))
#pragma warning restore
                {
                    continue;
                }

                msgFoldouts[msgId] = EditorGUILayout.Foldout(msgFoldouts[msgId], msgNames[msgId] + ":");
                if (msgFoldouts[msgId])
                {
                    EditorGUILayout.BeginVertical();
#pragma warning disable CS0618
                    var detail = NetworkDetailStats.m_NetworkOperations[msgId];
#pragma warning restore

                    EditorGUI.indentLevel += 1;

                    foreach (var entryName in detail.m_Entries.Keys)
                    {
                        int tick  = (int)Time.time;
                        var entry = detail.m_Entries[entryName];

                        if (entry.m_IncomingTotal > 0)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("IN:" + entryName);
                            EditorGUILayout.LabelField(entry.m_IncomingSequence.GetFiveTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_IncomingSequence.GetTenTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_IncomingTotal.ToString());
                            EditorGUILayout.EndHorizontal();
                        }

                        if (entry.m_OutgoingTotal > 0)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("OUT:" + entryName);
                            EditorGUILayout.LabelField(entry.m_OutgoingSequence.GetFiveTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_OutgoingSequence.GetTenTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_OutgoingTotal.ToString());
                            EditorGUILayout.EndHorizontal();
                        }
                    }

                    EditorGUI.indentLevel -= 1;
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUI.indentLevel -= 1;
            GUILayout.EndScrollView();
            SplitterGUILayout.EndHorizontalSplit();

            // Draw separator
            var lineRect = new Rect(m_NetworkSplit.realSizes[0] + labelRect.xMin, position.y - EditorGUI.kWindowToolbarHeight - 1, 1,
                                    position.height + EditorGUI.kWindowToolbarHeight);
            EditorGUI.DrawRect(lineRect, s_SeparatorColor);
        }
Ejemplo n.º 15
0
        public void OnGUI()
        {
            if (this.m_ScheduleRestoreSelection)
            {
                this.m_ScheduleRestoreSelection = false;
                if (this.m_PickingData.TryRestoreSelectedWindow(this.m_LastWindowTitle))
                {
                    this.EndPicking(this.m_PickingData.Selected);
                    this.m_VisualTreeTreeView.ExpandAll();
                }
                else
                {
                    this.m_LastWindowTitle = string.Empty;
                }
            }
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });
            bool flag = false;

            EditorGUI.BeginChangeCheck();
            this.m_PickingData.DoSelectDropDown();
            if (EditorGUI.EndChangeCheck())
            {
                flag = true;
            }
            if (GUILayout.Button("Refresh", EditorStyles.toolbarButton, new GUILayoutOption[]
            {
                GUILayout.Width(50f)
            }))
            {
                this.m_PickingData.Refresh();
            }
            bool flag2 = GUILayout.Toggle(this.m_VisualTreeTreeView.includeShadowHierarchy, UIElementsDebugger.Styles.includeShadowHierarchyContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);

            if (flag2 != this.m_VisualTreeTreeView.includeShadowHierarchy)
            {
                this.m_VisualTreeTreeView.includeShadowHierarchy = flag2;
                flag = true;
            }
            if (this.m_CurPanel.HasValue)
            {
                bool flag3 = GUILayout.Toggle(this.m_PickingElementInPanel, UIElementsDebugger.Styles.pickElementInPanelContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
                if (flag3 != this.m_PickingElementInPanel)
                {
                    this.m_PickingElementInPanel = flag3;
                    if (this.m_PickingElementInPanel)
                    {
                        this.m_CurPanel.Value.Panel.panelDebug.interceptEvents = new Func <Event, bool>(this.InterceptEvents);
                    }
                }
            }
            this.m_Overlay = GUILayout.Toggle(this.m_Overlay, UIElementsDebugger.Styles.overlayContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            bool uxmlLiveReloadIsEnabled = RetainedMode.UxmlLiveReloadIsEnabled;
            bool flag4 = GUILayout.Toggle(uxmlLiveReloadIsEnabled, UIElementsDebugger.Styles.liveReloadContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);

            if (flag4 != uxmlLiveReloadIsEnabled)
            {
                RetainedMode.UxmlLiveReloadIsEnabled = flag4;
            }
            EditorGUILayout.EndHorizontal();
            if (flag)
            {
                this.EndPicking(this.m_PickingData.Selected);
            }
            if (this.m_CurPanel.HasValue)
            {
                if (this.m_CurPanel.Value.Panel.panelDebug.enabled != this.m_Overlay)
                {
                    this.m_CurPanel.Value.Panel.panelDebug.enabled = this.m_Overlay;
                    this.m_CurPanel.Value.Panel.visualTree.Dirty(ChangeType.Repaint);
                }
                SplitterGUILayout.BeginHorizontalSplit(this.m_SplitterState, new GUILayoutOption[]
                {
                    GUILayout.ExpandWidth(true),
                    GUILayout.ExpandHeight(true)
                });
                SplitterGUILayout.EndHorizontalSplit();
                float num   = (float)((this.m_SplitterState.realSizes.Length <= 0) ? 150 : this.m_SplitterState.realSizes[0]);
                float width = base.position.width - num;
                Rect  rect  = new Rect(0f, 17f, num, base.position.height - 17f);
                Rect  rect2 = new Rect(num, 17f, width, rect.height);
                this.m_VisualTreeTreeView.OnGUI(rect);
                this.DrawSelection(rect2);
                EditorGUI.DrawRect(new Rect(num + rect.xMin, rect.y, 1f, rect.height), UIElementsDebugger.Styles.separatorColor);
            }
        }
Ejemplo n.º 16
0
 public void OnGUI()
 {
     using (new AnimatorControllerTool.ScopedPreventWarnings(this.previewAnimator))
     {
         EventType type   = Event.current.type;
         int       button = Event.current.button;
         base.autoRepaintOnSceneChange = true;
         if (AnimatorControllerTool.s_Styles == null)
         {
             AnimatorControllerTool.s_Styles = new AnimatorControllerTool.Styles();
         }
         this.OnControllerChange();
         BlendTreeInspector.currentController = this.m_AnimatorController;
         BlendTreeInspector.currentAnimator   = this.m_PreviewAnimator;
         if (this.miniTool)
         {
             Rect paneRect = new Rect(0f, 0f, base.position.width, base.position.height);
             this.OnGUIGraph(paneRect);
         }
         else
         {
             if (this.m_VerticalSplitter == null || this.m_VerticalSplitter.realSizes.Length != 2)
             {
                 this.m_VerticalSplitter = new SplitterState(new int[]
                 {
                     (int)(base.position.width * 0.25f),
                     (int)(base.position.width * 0.75f)
                 }, new int[]
                 {
                     150,
                     100
                 }, null);
             }
             SplitterGUILayout.BeginHorizontalSplit(this.m_VerticalSplitter, new GUILayoutOption[]
             {
                 GUILayout.ExpandWidth(true),
                 GUILayout.ExpandHeight(true)
             });
             SplitterGUILayout.EndHorizontalSplit();
             int  num            = this.m_VerticalSplitter.realSizes[0];
             int  num2           = this.m_VerticalSplitter.realSizes[1];
             Rect rect           = new Rect(0f, 0f, (float)num, base.position.height);
             Rect paneRect2      = new Rect((float)num, 0f, (float)num2, base.position.height);
             Rect topToolBarRect = new Rect(rect.x, rect.y, rect.width, 17f);
             this.OnGUIEditorToolbar(topToolBarRect);
             Rect editorRect = new Rect(0f, 17f, rect.width, rect.height - 17f);
             this.OnGUIEditor(editorRect);
             if (Event.current.type == EventType.MouseDown && this.editor.HasKeyboardControl())
             {
                 this.editor.ReleaseKeyboardFocus();
             }
             else if (this.activeGraphGUI != null && type == EventType.MouseDown && type != Event.current.type)
             {
                 this.activeGraphGUI.ClearSelection();
             }
             this.OnGUIGraph(paneRect2);
         }
         if (Event.current.type == EventType.MouseDown)
         {
             GUIUtility.keyboardControl = 0;
             EditorGUI.EndEditingActiveTextField();
         }
         if (this.activeGraphGUI != null && type == EventType.MouseDown && button == 0 && this.activeGraphGUI.selection.Count == 0 && this.activeGraphGUI.edgeGUI.edgeSelection.Count == 0)
         {
             this.activeGraphGUI.DoBackgroundClickAction();
         }
     }
 }
Ejemplo n.º 17
0
        public void OnGUI()
        {
            if (!m_Enabled)
            {
                Enable();
            }

            if (BuildPipeline.isBuildingPlayer)
            {
                m_IsBuilding = true;
            }
            else if (m_IsBuilding)
            {
                m_IsBuilding = false;
                Repaint();
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            var selectedIndex = m_TestTypeToolbarIndex;

            m_TestTypeToolbarIndex = GUILayout.Toolbar(m_TestTypeToolbarIndex, Enum.GetNames(typeof(TestRunnerMenuLabels)), "LargeButton", UnityEngine.GUI.ToolbarButtonSize.FitToContents);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            if (selectedIndex != m_TestTypeToolbarIndex)
            {
                SelectTestListGUI(m_TestTypeToolbarIndex);
                StartRetrieveTestList();
            }

            EditorGUILayout.BeginVertical();
            using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
            {
                m_SelectedTestTypes.PrintHeadPanel();
            }
            EditorGUILayout.EndVertical();

            if (m_Settings.verticalSplit)
            {
                SplitterGUILayout.BeginVerticalSplit(m_Spl);
            }
            else
            {
                SplitterGUILayout.BeginHorizontalSplit(m_Spl);
            }

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginVertical(Styles.testList);
            m_SelectedTestTypes.RenderTestList();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndVertical();

            m_SelectedTestTypes.RenderDetails();

            if (m_Settings.verticalSplit)
            {
                SplitterGUILayout.EndVerticalSplit();
            }
            else
            {
                SplitterGUILayout.EndHorizontalSplit();
            }
        }
        public void DoGUI(HierarchyFrameDataView frameDataView, bool fetchData, ref bool updateViewLive, ProfilerViewType viewType)
        {
            using (m_DoGUIMarker.Auto())
            {
                if (Event.current.type != EventType.Layout && m_ThreadIndexDuringLastNonLayoutEvent != threadIndexInThreadNames)
                {
                    m_ThreadIndexDuringLastNonLayoutEvent = threadIndexInThreadNames;
                    EditorGUIUtility.ExitGUI();
                }
                InitIfNeeded();

                var isSearchAllowed = string.IsNullOrEmpty(treeView.searchString) || !(m_ProfilerWindow.ProfilerWindowOverheadIsAffectingProfilingRecordingData() && ProfilerDriver.deepProfiling);

                var isDataAvailable = frameDataView != null && frameDataView.valid;

                var showDetailedView = isDataAvailable && m_DetailedViewType != DetailedViewType.None;
                if (showDetailedView)
                {
                    SplitterGUILayout.BeginHorizontalSplit(m_DetailedViewSpliterState);
                }

                // Hierarchy view area
                GUILayout.BeginVertical();

                if (isDataAvailable && (threadIndex != frameDataView.threadIndex || threadName != frameDataView.threadName))
                {
                    SetFrameDataView(frameDataView);
                }

                DrawToolbar(frameDataView, showDetailedView, ref updateViewLive, viewType);

                if (!string.IsNullOrEmpty(dataAvailabilityMessage))
                {
                    GUILayout.Label(dataAvailabilityMessage, BaseStyles.label);
                }
                else if (!isDataAvailable)
                {
                    if (!fetchData && !updateViewLive)
                    {
                        GUILayout.Label(BaseStyles.liveUpdateMessage, BaseStyles.label);
                    }
                    else
                    {
                        GUILayout.Label(BaseStyles.noData, BaseStyles.label);
                    }
                }
                else if (!isSearchAllowed)
                {
                    GUILayout.Label(BaseStyles.disabledSearchText, BaseStyles.label);
                }
                else
                {
                    var rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandHeight(true));

                    m_TreeView.SetFrameDataView(frameDataView);
                    m_TreeView.OnGUI(rect, updateViewLive);

                    if (m_TreeView.HasSelection() && m_TreeView.proxySelectionInfo.hasProxySelection)
                    {
                        if (m_TreeView.proxySelectionInfo.cachedDisplayContent == null)
                        {
                            var diff = Math.Abs(m_TreeView.proxySelectionInfo.pathLengthDifferenceForProxy);
                            m_TreeView.proxySelectionInfo.cachedDisplayContent = new GUIContent(
                                BaseStyles.selectionExtraInfoHierarhcyView + string.Format(
                                    BaseStyles.proxySampleMessage,
                                    m_TreeView.proxySelectionInfo.nonProxyName, diff,
                                    diff == 1 ? BaseStyles.proxySampleMessageScopeSingular : BaseStyles.proxySampleMessageScopePlural),
                                BaseStyles.warningTriangle.image);
                        }
                        GUILayout.BeginHorizontal();
                        GUILayout.Box(m_TreeView.proxySelectionInfo.cachedDisplayContent, BaseStyles.selectionExtraInfoArea);
                        var rectForSampleStackButton = GUILayoutUtility.GetRect(BaseStyles.showDetailsDropdownContent, BaseStyles.tooltipDropdown, GUILayout.ExpandHeight(false), GUILayout.ExpandHeight(false));
                        if (GUI.Button(rectForSampleStackButton, BaseStyles.showDetailsDropdownContent, BaseStyles.tooltipDropdown))
                        {
                            var selection  = m_TreeView.GetSelection();
                            var selectedId = (selection != null && selection.Count > 0) ? selection[0] : ProfilerFrameDataHierarchyView.invalidTreeViewId;
                            if (selectedId >= 0)
                            {
                                var menu = new GenericMenu();

                                // Show Sample Selection:
                                var rawSampleIndices = new List <int>(frameDataView.GetItemMergedSamplesCount(selectedId));
                                frameDataView.GetItemRawFrameDataViewIndices(selectedId, rawSampleIndices);
                                var actualMarkerIdPath = new List <int>(frameDataView.GetItemDepth(selectedId));
                                using (var iterator = new RawFrameDataView(frameDataView.frameIndex, frameDataView.threadIndex))
                                {
                                    string name     = null;
                                    var    rawIndex = ProfilerTimelineGUI.GetItemMarkerIdPath(iterator, cpuModule, rawSampleIndices[0], ref name, ref actualMarkerIdPath);
                                }

                                var actualMarkerPath = new List <string>(actualMarkerIdPath.Count);
                                foreach (var id in actualMarkerIdPath)
                                {
                                    if ((frameDataView.GetMarkerFlags(id) & Unity.Profiling.LowLevel.MarkerFlags.AvailabilityEditor) != 0)
                                    {
                                        actualMarkerPath.Add(string.Format("EditorOnly [{0}]", frameDataView.GetMarkerName(id)));
                                    }
                                    else
                                    {
                                        actualMarkerPath.Add(frameDataView.GetMarkerName(id));
                                    }
                                }

                                // admittedly, it'd be nice to only generate the text if sample selection option was chosen...
                                // however, that would need to happen in an OnGui call and not within the callback of the generic menu,
                                // to be able to calculate the needed window size and avoid glitches on first displaying it.
                                // at least the user already clicked on the dropdown for this...

                                string selectedSampleStackText = null;
                                var    sampleStackSb           = new System.Text.StringBuilder();
                                if (m_TreeView.proxySelectionInfo.nonProxySampleStack != null && m_TreeView.proxySelectionInfo.nonProxySampleStack.Count > 0)
                                {
                                    for (int i = m_TreeView.proxySelectionInfo.nonProxySampleStack.Count - 1; i >= 0; i--)
                                    {
                                        sampleStackSb.AppendLine(m_TreeView.proxySelectionInfo.nonProxySampleStack[i]);
                                    }
                                    selectedSampleStackText = sampleStackSb.ToString();
                                }
                                string actualSampleStackText = null;
                                if (actualMarkerPath != null && actualMarkerPath.Count > 0)
                                {
                                    sampleStackSb.Clear();

                                    for (int i = actualMarkerPath.Count - 1; i >= 0; i--)
                                    {
                                        sampleStackSb.AppendLine(actualMarkerPath[i]);
                                    }
                                    actualSampleStackText = sampleStackSb.ToString();
                                }

                                var selectionSampleStackContent = selectedSampleStackText != null ? new GUIContent(selectedSampleStackText) : null;
                                var actualSampleStackContent    = actualSampleStackText != null ? new GUIContent(actualSampleStackText) : null;
                                var sampleStackWindowSize       = SelectedSampleStackWindow.CalculateSize(selectionSampleStackContent, actualSampleStackContent);
                                menu.AddItem(BaseStyles.showSelectedSampleStacks, false, () =>
                                {
                                    SelectedSampleStackWindow.ShowSampleStackWindow(GUIUtility.GUIToScreenRect(rectForSampleStackButton).position, sampleStackWindowSize, selectionSampleStackContent, actualSampleStackContent);
                                });
                                menu.DropDown(rectForSampleStackButton);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                }

                GUILayout.EndVertical();

                if (showDetailedView)
                {
                    GUILayout.BeginVertical();

                    // Detailed view area
                    EditorGUILayout.BeginHorizontal(BaseStyles.toolbar);

                    DrawDetailedViewPopup();
                    GUILayout.FlexibleSpace();

                    cpuModule.DrawOptionsMenuPopup();
                    EditorGUILayout.EndHorizontal();

                    switch (m_DetailedViewType)
                    {
                    case DetailedViewType.Objects:
                        detailedObjectsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                        break;

                    case DetailedViewType.CallersAndCallees:
                        detailedCallsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection());
                        break;
                    }

                    GUILayout.EndVertical();

                    SplitterGUILayout.EndHorizontalSplit();
                }

                HandleKeyboardEvents();
            }
        }
        public void OnGUI()
        {
            if (!_initialized)
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                GUILayout.FlexibleSpace();
                GUILayout.Label("Loading...");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                return;
            }

            // Make sure that editor options are synchronized
            BurstEditorOptions.EnsureSynchronized();

            if (_fontSizesText == null)
            {
                _fontSizesText = new string[FontSizes.Length];
                for (var i = 0; i < FontSizes.Length; ++i)
                {
                    _fontSizesText[i] = FontSizes[i].ToString();
                }
            }

            if (_fontSizeIndex == -1)
            {
                _fontSizeIndex = EditorPrefs.GetInt(FontSizeIndexPref, 5);
                _fontSizeIndex = Math.Max(0, _fontSizeIndex);
                _fontSizeIndex = Math.Min(_fontSizeIndex, FontSizes.Length - 1);
            }

            if (_fixedFontStyle == null)
            {
                _fixedFontStyle = new GUIStyle(GUI.skin.label);
                string fontName;
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    fontName = "Consolas";
                }
                else
                {
                    fontName = "Courier";
                }

                CleanupFont();

                _font = Font.CreateDynamicFontFromOSFont(fontName, FontSize);
                _fixedFontStyle.font     = _font;
                _fixedFontStyle.fontSize = FontSize;
            }

            if (_searchField == null)
            {
                _searchField = new SearchField();
            }

            if (_textArea == null)
            {
                _textArea = new LongTextArea();
            }

            GUILayout.BeginHorizontal();

            // SplitterGUILayout.BeginHorizontalSplit is internal in Unity but we don't have much choice
            SplitterGUILayout.BeginHorizontalSplit(TreeViewSplitterState);

            GUILayout.BeginVertical(GUILayout.Width(position.width / 3));

            GUILayout.Label("Compile Targets", EditorStyles.boldLabel);

            var newFilter = _searchField.OnGUI(_treeView.Filter);

            if (newFilter != _treeView.Filter)
            {
                _treeView.Filter = newFilter;
                _treeView.Reload();
            }

            _treeView.OnGUI(GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)));

            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            var selection = _treeView.GetSelection();

            if (selection.Count == 1)
            {
                var targetIndex   = selection[0];
                var target        = _targets[targetIndex - 1];
                var targetOptions = target.Options;

                // Stash selected item name to handle domain reloads more gracefully
                _selectedItem = target.GetDisplayName();

                if (_assemblyKind == -1)
                {
                    if (_enhancedDisassembly)
                    {
                        _assemblyKind = (int)AssemblyKind.ColouredMinimalDebugInformation;
                    }
                    else
                    {
                        _assemblyKind = (int)AssemblyKind.RawNoDebugInformation;
                    }
                }

                // Refresh if any options are changed
                bool doCopy;
                int  fontSize;
                // -14 to add a little bit of space for the vertical scrollbar to display correctly
                RenderButtonBars((position.width * 2) / 3 - 14, target, out doCopy, out fontSize);

                // We are currently formatting only Asm output
                var isTextFormatted = IsEnhanced((AssemblyKind)_assemblyKind) && _disasmKind == DisassemblyKind.Asm;

                // Depending if we are formatted or not, we don't render the same text
                var textToRender = isTextFormatted ? target.FormattedDisassembly : target.RawDisassembly;

                // Only refresh if we are switching to a new selection that hasn't been disassembled yet
                // Or we are changing disassembly settings (safety checks / enhanced disassembly)
                var targetRefresh = textToRender == null ||
                                    target.DisassemblyKind != _disasmKind ||
                                    targetOptions.EnableBurstSafetyChecks != _safetyChecks ||
                                    target.TargetCpu != _targetCpu ||
                                    target.IsDarkMode != EditorGUIUtility.isProSkin;

                bool targetChanged = _previousTargetIndex != targetIndex;

                _previousTargetIndex = targetIndex;

                if (_assemblyKindPrior != _assemblyKind)
                {
                    targetRefresh      = true;
                    _assemblyKindPrior = _assemblyKind;     // Needs to be refreshed, as we need to change disassembly options

                    // If the target did not changed but our assembly kind did, we need to remember this.
                    if (!targetChanged)
                    {
                        _sameTargetButDifferentAssemblyKind = true;
                    }
                }

                // If the previous target changed the assembly kind and we have a target change, we need to
                // refresh the assembly because we'll have cached the previous assembly kinds output rather
                // than the one requested.
                if (_sameTargetButDifferentAssemblyKind && targetChanged)
                {
                    targetRefresh = true;
                    _sameTargetButDifferentAssemblyKind = false;
                }

                if (targetRefresh)
                {
                    // TODO: refactor this code with a proper AppendOption to avoid these "\n"
                    var options = new StringBuilder();

                    target.TargetCpu       = _targetCpu;
                    target.DisassemblyKind = _disasmKind;
                    targetOptions.EnableBurstSafetyChecks = _safetyChecks;
                    target.IsDarkMode = EditorGUIUtility.isProSkin;
                    targetOptions.EnableBurstCompileSynchronously = true;

                    string defaultOptions;
                    if (targetOptions.TryGetOptions(target.IsStaticMethod ? (MemberInfo)target.Method : target.JobType, true, out defaultOptions))
                    {
                        options.Append(defaultOptions);

                        options.AppendFormat("\n" + BurstCompilerOptions.GetOption(BurstCompilerOptions.OptionTarget, TargetCpuNames[(int)_targetCpu]));

                        switch ((AssemblyKind)_assemblyKind)
                        {
                        case AssemblyKind.EnhancedMinimalDebugInformation:
                        case AssemblyKind.ColouredMinimalDebugInformation:
                            options.AppendFormat("\n" + BurstCompilerOptions.GetOption(BurstCompilerOptions.OptionDebug, "2"));
                            break;

                        case AssemblyKind.ColouredFullDebugInformation:
                        case AssemblyKind.EnhancedFullDebugInformation:
                        case AssemblyKind.RawWithDebugInformation:
                            options.AppendFormat("\n" + BurstCompilerOptions.GetOption(BurstCompilerOptions.OptionDebug, "1"));
                            break;

                        default:
                        case AssemblyKind.RawNoDebugInformation:
                            break;
                        }

                        var baseOptions = options.ToString().Trim('\n', ' ');

                        target.RawDisassembly = GetDisassembly(target.Method, baseOptions + DisasmOptions[(int)_disasmKind]);

                        if (isTextFormatted)
                        {
                            target.FormattedDisassembly = _burstDisassembler.Process(target.RawDisassembly, FetchAsmKind(_targetCpu), target.IsDarkMode, IsColoured((AssemblyKind)_assemblyKind));
                            textToRender = target.FormattedDisassembly;
                        }
                        else
                        {
                            target.FormattedDisassembly = null;
                            textToRender = target.RawDisassembly;
                        }
                    }
                }

                if (textToRender != null)
                {
                    _textArea.Text = textToRender;
                    if (targetChanged)
                    {
                        _scrollPos = Vector2.zero;
                    }
                    _scrollPos = GUILayout.BeginScrollView(_scrollPos, true, true);
                    _textArea.Render(_fixedFontStyle);
                    GUILayout.EndScrollView();
                }

                if (doCopy)
                {
                    // When copying to the clipboard, we copy the version the user sees
                    EditorGUIUtility.systemCopyBuffer = textToRender ?? string.Empty;
                }

                if (fontSize != _fontSizeIndex)
                {
                    _fontSizeIndex = fontSize;
                    EditorPrefs.SetInt(FontSizeIndexPref, fontSize);
                    _fixedFontStyle = null;
                }
            }

            GUILayout.EndVertical();

            SplitterGUILayout.EndHorizontalSplit();

            GUILayout.EndHorizontal();
        }
Ejemplo n.º 20
0
        void DrawNetworkOperationsPane()
        {
            SplitterGUILayout.BeginHorizontalSplit(m_NetworkSplit);

            GUILayout.Label(ProfilerDriver.GetOverviewText(ProfilerArea.NetworkOperations, m_ProfilerWindow.GetActiveVisibleFrameIndex()), EditorStyles.wordWrappedLabel);

            m_PaneScroll = GUILayout.BeginScrollView(m_PaneScroll, ProfilerWindow.Styles.background);

            EditorGUILayout.BeginHorizontal(EditorStyles.contentToolbar);
            EditorGUILayout.LabelField("Operation Detail");
            EditorGUILayout.LabelField("Over 5 Ticks");
            EditorGUILayout.LabelField("Over 10 Ticks");
            EditorGUILayout.LabelField("Total");
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel += 1;

            for (short msgId = 0; msgId < msgNames.Length; msgId++)
            {
#pragma warning disable CS0618
                if (!NetworkDetailStats.m_NetworkOperations.ContainsKey(msgId))
#pragma warning restore
                {
                    continue;
                }

                msgFoldouts[msgId] = EditorGUILayout.Foldout(msgFoldouts[msgId], msgNames[msgId] + ":");
                if (msgFoldouts[msgId])
                {
                    EditorGUILayout.BeginVertical();
#pragma warning disable CS0618
                    var detail = NetworkDetailStats.m_NetworkOperations[msgId];
#pragma warning restore

                    EditorGUI.indentLevel += 1;

                    foreach (var entryName in detail.m_Entries.Keys)
                    {
                        int tick  = (int)Time.time;
                        var entry = detail.m_Entries[entryName];

                        if (entry.m_IncomingTotal > 0)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("IN:" + entryName);
                            EditorGUILayout.LabelField(entry.m_IncomingSequence.GetFiveTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_IncomingSequence.GetTenTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_IncomingTotal.ToString());
                            EditorGUILayout.EndHorizontal();
                        }

                        if (entry.m_OutgoingTotal > 0)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("OUT:" + entryName);
                            EditorGUILayout.LabelField(entry.m_OutgoingSequence.GetFiveTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_OutgoingSequence.GetTenTick(tick).ToString());
                            EditorGUILayout.LabelField(entry.m_OutgoingTotal.ToString());
                            EditorGUILayout.EndHorizontal();
                        }
                    }

                    EditorGUI.indentLevel -= 1;
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUI.indentLevel -= 1;
            GUILayout.EndScrollView();
            SplitterGUILayout.EndHorizontalSplit();
        }