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); }
//============================================================================================================// // 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(); }
public void DoGUI(GUIStyle headerStyle, int frameIndex, ProfilerViewType viewType) { string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; if (string.IsNullOrEmpty(selectedPropertyPath)) { base.DrawEmptyPane(headerStyle); } else { this.InitIfNeeded(); this.UpdateIfNeeded(frameIndex, viewType, selectedPropertyPath); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Label(this.m_TotalSelectedPropertyTimeLabel, EditorStyles.label, new GUILayoutOption[0]); SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); Rect r = EditorGUILayout.BeginVertical(new GUILayoutOption[0]); this.m_CalleesTreeView.OnGUI(r); EditorGUILayout.EndVertical(); r = EditorGUILayout.BeginVertical(new GUILayoutOption[0]); this.m_CallersTreeView.OnGUI(r); EditorGUILayout.EndVertical(); SplitterGUILayout.EndHorizontalSplit(); GUILayout.EndVertical(); } }
public void DoGUI(GUIStyle headerStyle, FrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.IsValid() || selection.Count == 0) { DrawEmptyPane(headerStyle); return; } var selectedId = selection[0]; InitIfNeeded(); UpdateIfNeeded(frameDataView, selectedId); GUILayout.Label(m_TotalSelectedPropertyTimeLabel, EditorStyles.label); SplitterGUILayout.BeginVerticalSplit(m_VertSplit, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); // Callees var rect = EditorGUILayout.BeginHorizontal(); m_CalleesTreeView.OnGUI(rect); EditorGUILayout.EndHorizontal(); // Callers rect = EditorGUILayout.BeginHorizontal(); m_CallersTreeView.OnGUI(rect); EditorGUILayout.EndHorizontal(); SplitterGUILayout.EndVerticalSplit(); }
public void DoGUI(GUIStyle headerStyle, FrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.IsValid() || selection.Count == 0) { base.DrawEmptyPane(headerStyle); } else { int selectedId = selection[0]; this.InitIfNeeded(); this.UpdateIfNeeded(frameDataView, selectedId); GUILayout.Label(this.m_TotalSelectedPropertyTimeLabel, EditorStyles.label, new GUILayoutOption[0]); SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); Rect r = EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); this.m_CalleesTreeView.OnGUI(r); EditorGUILayout.EndHorizontal(); r = EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); this.m_CallersTreeView.OnGUI(r); EditorGUILayout.EndHorizontal(); SplitterGUILayout.EndVerticalSplit(); } }
void DrawDetailedMemoryPane(SplitterState splitter) { SplitterGUILayout.BeginHorizontalSplit(splitter); m_MemoryListView.OnGUI(); m_ReferenceListView.OnGUI(); SplitterGUILayout.EndHorizontalSplit(); }
void DoUpdateReportArea( UpdateReportListView updateReportListView, object splitterState) { SplitterGUILayout.BeginHorizontalSplit(splitterState); DoUpdateReportViewArea(updateReportListView); DoErrorDetailsTextArea(updateReportListView.GetSelectedError()); SplitterGUILayout.EndHorizontalSplit(); }
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(); }
void DoListArea( UpdateReportListView errorsListView, object splitterState) { EditorGUILayout.BeginVertical(); SplitterGUILayout.BeginHorizontalSplit(splitterState); DoErrorsListViewArea(errorsListView); DoErrorDetailsTextArea(errorsListView.GetSelectedError()); SplitterGUILayout.EndHorizontalSplit(); EditorGUILayout.EndVertical(); }
public void DoGUI(GUIStyle headerStyle, FrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.IsValid() || selection.Count == 0) { DrawEmptyPane(headerStyle); return; } InitIfNeeded(); UpdateIfNeeded(frameDataView, selection[0]); string callstack = null; var selectedSampleId = m_TreeView.GetSelectedFrameDataViewId(); if (selectedSampleId != -1) { callstack = frameDataView.ResolveItemCallstack(selectedSampleId, m_TreeView.state.selectedIDs[0]); } var showCallstack = !string.IsNullOrEmpty(callstack); if (showCallstack) { SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea); } // Detailed list var rect = EditorGUILayout.BeginVertical(Styles.expandedArea); m_TreeView.OnGUI(rect); EditorGUILayout.EndVertical(); if (showCallstack) { // Callstack area EditorGUILayout.BeginVertical(Styles.expandedArea); m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll); var text = kCallstackText + '\n' + callstack; EditorGUILayout.TextArea(text, Styles.callstackTextArea); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); } }
void IIncomingChangesTab.OnGUI() { DoActionsToolbar( mIsProcessMergesButtonVisible, mIsCancelMergesButtonVisible, mIsProcessMergesButtonEnabled, mIsCancelMergesButtonEnabled, mProcessMergesButtonText, mIncomingChangesViewLogic, mIncomingChangesTreeView, mProgressControls); bool splitterNeeded = mIsErrorsListVisible; if (splitterNeeded) { SplitterGUILayout.BeginVerticalSplit(mErrorsSplitterState); } DoIncomingChangesArea( mPlasticClient, mIncomingChangesTreeView, mPendingConflictsLabelData, mChangesToApplySummaryLabelText, mMessageLabelText, mIsMessageLabelVisible, mProgressControls.IsOperationRunning()); DoErrorsArea( mErrorsListView, mErrorDetailsSplitterState, mErrorMessageLabelText, mIsErrorsListVisible, mIsErrorMessageLabelVisible); if (splitterNeeded) { SplitterGUILayout.EndVerticalSplit(); } if (mProgressControls.HasNotification()) { DrawProgressForViews.ForNotificationArea( mProgressControls.ProgressData); } }
internal IncomingChangesTab( WorkspaceInfo wkInfo, ViewHost viewHost, PlasticGUIClient plasticClient, NewIncomingChangesUpdater newIncomingChangesUpdater, CheckIncomingChanges.IUpdateIncomingChanges updateIncomingChanges, EditorWindow parentWindow) { mWkInfo = wkInfo; mPlasticClient = plasticClient; mNewIncomingChangesUpdater = newIncomingChangesUpdater; mParentWindow = parentWindow; BuildComponents(); mProgressControls = new ProgressControlsForViews(); mErrorsSplitterState = SplitterGUILayout.InitSplitterState( new float[] { 0.75f, 0.25f }, new int[] { 100, 100 }, new int[] { 100000, 100000 } ); mErrorDetailsSplitterState = SplitterGUILayout.InitSplitterState( new float[] { 0.60f, 0.40f }, new int[] { 100, 100 }, new int[] { 100000, 100000 } ); mIncomingChangesViewLogic = new IncomingChangesViewLogic( wkInfo, viewHost, this, new UnityPlasticGuiMessage(parentWindow), mProgressControls, updateIncomingChanges, plasticClient.GluonProgressOperationHandler, plasticClient, new IncomingChangesViewLogic.ApplyWorkspaceLocalChanges(), new IncomingChangesViewLogic.OutOfDateItemsOperations(), new IncomingChangesViewLogic.ResolveUserName(), new IncomingChangesViewLogic.GetWorkingBranch(), NewChangesInWk.Build(wkInfo, new BuildWorkspacekIsRelevantNewChange()), null); mIncomingChangesViewLogic.Refresh(); }
void BuildComponenets(WorkspaceInfo wkInfo) { mErrorDetailsSplitterState = SplitterGUILayout.InitSplitterState( new float[] { 0.50f, 0.50f }, new int[] { 100, 100 }, new int[] { 100000, 100000 } ); UpdateReportListHeaderState errorsListHeaderState = UpdateReportListHeaderState.Default; TreeHeaderSettings.Load(errorsListHeaderState, UnityConstants.DEVELOPER_UPDATE_REPORT_TABLE_SETTINGS_NAME, UnityConstants.UNSORT_COLUMN_ID); mPathsListView = new UpdateReportListView( wkInfo, errorsListHeaderState, OnCheckedReportLineChanged); mPathsListView.Reload(); }
internal ChangesetsTab( WorkspaceInfo wkInfo, IWorkspaceWindow workspaceWindow, IViewSwitcher viewSwitcher, EditorWindow parentWindow, bool isGluonMode) { mWkInfo = wkInfo; mParentWindow = parentWindow; mIsGluonMode = isGluonMode; BuildComponents( wkInfo, workspaceWindow, viewSwitcher, parentWindow); mProgressControls = new ProgressControlsForViews(); mSplitterState = SplitterGUILayout.InitSplitterState( new float[] { 0.50f, 0.50f }, new int[] { 100, 100 }, new int[] { 100000, 100000 } ); }
internal void OnGUI() { InitializeShowChangesButtonWidth(); bool wasChangesPanelVisible = mIsChangesPanelVisible; DoActionsToolbar( this, mProgressControls, mSearchField, mChangesetsListView, mDateFilter, mChangesetsLabelText, mShowChangesButtonWidth, wasChangesPanelVisible); if (mIsChangesPanelVisible) { SplitterGUILayout.BeginVerticalSplit(mSplitterState); } DoChangesetsArea( mChangesetsListView, mProgressControls.IsOperationRunning()); if (mIsChangesPanelVisible) { if (!wasChangesPanelVisible) { mShouldScrollToSelection = true; } DoChangesArea(mDiffPanel); SplitterGUILayout.EndVerticalSplit(); } }
static UpdateReportDialog Create( WorkspaceInfo wkInfo, List <ErrorMessage> errors) { var instance = CreateInstance <UpdateReportDialog>(); instance.mWkInfo = wkInfo; instance.mErrors = errors; instance.mEscapeKeyAction = instance.CloseButtonAction; instance.BuildComponents(instance.mWkInfo); instance.mErrorDetailsSplitterState = SplitterGUILayout.InitSplitterState( new float[] { 0.50f, 0.50f }, new int[] { 100, 100 }, new int[] { 100000, 100000 } ); UpdateUpdateReportList( instance.mUpdateReportListView, instance.mErrors); return(instance); }
public void DoGUI(GUIStyle headerStyle, FrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.IsValid() || selection.Count == 0) { base.DrawEmptyPane(headerStyle); } else { this.InitIfNeeded(); this.UpdateIfNeeded(frameDataView, selection[0]); string text = null; int selectedFrameDataViewId = this.m_TreeView.GetSelectedFrameDataViewId(); if (selectedFrameDataViewId != -1) { text = frameDataView.ResolveItemCallstack(selectedFrameDataViewId, this.m_TreeView.state.selectedIDs[0]); } bool flag = !string.IsNullOrEmpty(text); if (flag) { SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit, ProfilerDetailedView.Styles.expandedArea, new GUILayoutOption[0]); } Rect rect = EditorGUILayout.BeginVertical(ProfilerDetailedView.Styles.expandedArea, new GUILayoutOption[0]); this.m_TreeView.OnGUI(rect); EditorGUILayout.EndVertical(); if (flag) { EditorGUILayout.BeginVertical(ProfilerDetailedView.Styles.expandedArea, new GUILayoutOption[0]); this.m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(this.m_CallstackScrollViewPos, ProfilerDetailedView.Styles.callstackScroll, new GUILayoutOption[0]); string text2 = ProfilerDetailedObjectsView.kCallstackText + '\n' + text; EditorGUILayout.TextArea(text2, ProfilerDetailedView.Styles.callstackTextArea, new GUILayoutOption[0]); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); } } }
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); } }
public static void EndVerticalSplit() => SplitterGUILayout.EndVerticalSplit();
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 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(); } } }
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(); } }
public void DoGUI(GUIStyle headerStyle, HierarchyFrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.valid || selection.Count == 0) { DrawEmptyPane(headerStyle); return; } InitIfNeeded(); UpdateIfNeeded(frameDataView, selection[0]); var selectedSampleId = m_TreeView.GetSelectedFrameDataViewId(); var selectedMergedSampleIndex = m_TreeView.GetSelectedFrameDataViewMergedSampleIndex(); var selectedSampleMetadataCount = 0; if (selectedSampleId != -1) { frameDataView.GetItemMergedSampleCallstack(selectedSampleId, selectedMergedSampleIndex, m_CachedCallstack); selectedSampleMetadataCount = frameDataView.GetItemMergedSamplesMetadataCount(selectedSampleId, selectedMergedSampleIndex); } var showCallstack = m_CachedCallstack.Count > 0; var showMetadata = selectedSampleMetadataCount != 0; SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea); // Detailed list var rect = EditorGUILayout.BeginVertical(Styles.expandedArea); m_TreeView.OnGUI(rect); EditorGUILayout.EndVertical(); // Callstack area EditorGUILayout.BeginVertical(Styles.expandedArea); // Display active text (We want word wrapped text with a vertical scrollbar) m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll); var sb = new StringBuilder(); if (showMetadata || showCallstack) { if (showMetadata) { var metadataInfo = frameDataView.GetMarkerMetadataInfo(frameDataView.GetItemMarkerID(selectedSampleId)); sb.Append(kMetadataText); sb.Append('\n'); for (var i = 0; i < selectedSampleMetadataCount; ++i) { if (metadataInfo != null && i < metadataInfo.Length) { sb.Append(metadataInfo[i].name); } else { sb.Append(i); } sb.Append(": "); sb.Append(frameDataView.GetItemMergedSamplesMetadata(selectedSampleId, selectedMergedSampleIndex, i)); sb.Append('\n'); } sb.Append('\n'); } if (showCallstack) { sb.Append(kCallstackText); sb.Append('\n'); foreach (var addr in m_CachedCallstack) { var methodInfo = frameDataView.ResolveMethodInfo(addr); if (string.IsNullOrEmpty(methodInfo.methodName)) { sb.AppendFormat("0x{0:X}\n", addr); } else if (string.IsNullOrEmpty(methodInfo.sourceFileName)) { sb.AppendFormat("0x{0:X}\t\t{1}\n", addr, methodInfo.methodName); } else { var normalizedPath = methodInfo.sourceFileName.Replace('\\', '/'); if (methodInfo.sourceFileLine == 0) { sb.AppendFormat("0x{0:X}\t\t{1}\t<a href=\"{2}\" line=\"1\">{2}</a>\n", addr, methodInfo.methodName, normalizedPath); } else { sb.AppendFormat("0x{0:X}\t\t{1}\t<a href=\"{2}\" line=\"{3}\">{2}:{3}</a>\n", addr, methodInfo.methodName, normalizedPath, methodInfo.sourceFileLine); } } } } } else { sb.Append(kNoMetadataOrCallstackText); } var metadataText = sb.ToString(); Styles.callstackTextArea.CalcMinMaxWidth(GUIContent.Temp(metadataText), out _, out var maxWidth); float minHeight = Styles.callstackTextArea.CalcHeight(GUIContent.Temp(metadataText), maxWidth); EditorGUILayout.SelectableLabel(metadataText, Styles.callstackTextArea, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinWidth(maxWidth + 10), GUILayout.MinHeight(minHeight + 10)); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); }
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(); } }
void OnGUI() { Event e = Event.current; LoadIcons(); LogEntries.wrapped.UpdateEntries(); if (!m_HasUpdatedGuiStyles) { m_LineHeight = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight); m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom; UpdateListView(); } GUILayout.BeginHorizontal(Constants.Toolbar); if (GUILayout.Button(Constants.ClearLabel, Constants.MiniButton)) { LogEntries.Clear(); GUIUtility.keyboardControl = 0; } int currCount = LogEntries.wrapped.GetCount(); if (m_ListView.totalRows != currCount && m_ListView.totalRows > 0) { // scroll bar was at the bottom? if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight; } } if (LogEntries.wrapped.searchFrame) { LogEntries.wrapped.searchFrame = false; int selectedIndex = LogEntries.wrapped.GetSelectedEntryIndex(); if (selectedIndex != -1) { int showIndex = selectedIndex + 1; if (currCount > showIndex) { int showCount = ms_LVHeight / RowHeight; showIndex = showIndex + showCount / 2; } m_ListView.scrollPos.y = showIndex * RowHeight - ms_LVHeight; } } EditorGUILayout.Space(); bool wasCollapsed = LogEntries.wrapped.collapse; LogEntries.wrapped.collapse = GUILayout.Toggle(wasCollapsed, Constants.CollapseLabel, Constants.MiniButton); bool collapsedChanged = (wasCollapsed != LogEntries.wrapped.collapse); if (collapsedChanged) { // unselect if collapsed flag changed m_ListView.row = -1; // scroll to bottom m_ListView.scrollPos.y = LogEntries.wrapped.GetCount() * RowHeight; } SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton)); #if UNITY_2019_1_OR_NEWER SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton)); #endif SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton)); #if UNITY_2018_3_OR_NEWER ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown); #endif EditorGUILayout.Space(); if (m_DevBuild) { GUILayout.FlexibleSpace(); SetFlag(ConsoleFlags.StopForAssert, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForAssert), Constants.StopForAssertLabel, Constants.MiniButton)); SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForError), Constants.StopForErrorLabel, Constants.MiniButton)); } GUILayout.FlexibleSpace(); // Search bar GUILayout.Space(4f); SearchField(e); int errorCount = 0, warningCount = 0, logCount = 0; LogEntries.wrapped.GetCountsByType(ref errorCount, ref warningCount, ref logCount); EditorGUI.BeginChangeCheck(); bool setLogFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton); bool setWarningFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton); bool setErrorFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButton); // Active entry index may no longer be valid if (EditorGUI.EndChangeCheck()) { } LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelLog, setLogFlag); LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelWarning, setWarningFlag); LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelError, setErrorFlag); if (GUILayout.Button(new GUIContent(errorCount > 0 ? iconFirstErrorSmall : iconFirstErrorMono, Constants.FirstErrorLabel), Constants.MiniButton)) { int firstErrorIndex = LogEntries.wrapped.GetFirstErrorEntryIndex(); if (firstErrorIndex != -1) { SetActiveEntry(firstErrorIndex); LogEntries.wrapped.searchFrame = true; } } GUILayout.EndHorizontal(); SplitterGUILayout.BeginVerticalSplit(spl); int rowHeight = RowHeight; EditorGUIUtility.SetIconSize(new Vector2(rowHeight, rowHeight)); GUIContent tempContent = new GUIContent(); int id = GUIUtility.GetControlID(0); int rowDoubleClicked = -1; /////@TODO: Make Frame selected work with ListViewState using (new GettingLogEntriesScope(m_ListView)) { int selectedRow = -1; bool openSelectedItem = false; bool collapsed = LogEntries.wrapped.collapse; foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, Constants.Box)) { if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition)) { m_ListView.row = el.row; selectedRow = el.row; if (e.clickCount == 2) { openSelectedItem = true; } } else if (e.type == EventType.Repaint) { int mode = 0; int entryCount = 0; int searchIndex = 0; int searchEndIndex = 0; string text = LogEntries.wrapped.GetEntryLinesAndFlagAndCount(el.row, ref mode, ref entryCount, ref searchIndex, ref searchEndIndex); ConsoleFlags flag = (ConsoleFlags)mode; bool isSelected = LogEntries.wrapped.IsEntrySelected(el.row); // Draw the background GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground; s.Draw(el.position, false, false, isSelected, false); // Draw the icon #if !UNITY_2017_3_OR_NEWER if (Constants.LogStyleLineCount == 1) { Rect rt = el.position; rt.x += 6f; rt.y += 2f; rt.width = 16f; rt.height = 16f; GUI.DrawTexture(rt, GetIconForErrorMode(flag, false)); } else #endif { GUIStyle iconStyle = GetStyleForErrorMode(flag, true, Constants.LogStyleLineCount == 1); iconStyle.Draw(el.position, false, false, isSelected, false); } // Draw the text tempContent.text = text; GUIStyle errorModeStyle = GetStyleForErrorMode(flag, false, Constants.LogStyleLineCount == 1); if (string.IsNullOrEmpty(LogEntries.wrapped.searchString) || searchIndex == -1 || searchIndex >= text.Length) { errorModeStyle.Draw(el.position, tempContent, id, isSelected); } else { errorModeStyle.DrawWithTextSelection(el.position, tempContent, GUIUtility.keyboardControl, searchIndex, searchEndIndex); } if (collapsed) { Rect badgeRect = el.position; tempContent.text = entryCount.ToString(CultureInfo.InvariantCulture); Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent); badgeRect.xMin = badgeRect.xMax - badgeSize.x; badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f; badgeRect.x -= 5f; GUI.Label(badgeRect, tempContent, Constants.CountBadge); } } } if (selectedRow != -1) { if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1; } } // Make sure the selected entry is up to date if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0) { } else { if (m_ListView.selectionChanged) { SetActiveEntry(m_ListView.row); } } // Open entry using return key if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0)) { selectedRow = m_ListView.row; openSelectedItem = true; } if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1) { ms_LVHeight = ListViewGUI.ilvState.rectHeight; } if (openSelectedItem) { rowDoubleClicked = selectedRow; e.Use(); } if (selectedRow != -1) { SetActiveEntry(selectedRow); } } // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060. if (rowDoubleClicked != -1) { LogEntries.wrapped.StacktraceListView_RowGotDoubleClicked(); } EditorGUIUtility.SetIconSize(Vector2.zero); StacktraceListView(e, tempContent); SplitterGUILayout.EndVerticalSplit(); // Copy & Paste selected item if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == "Copy") { if (e.type == EventType.ExecuteCommand) { LogEntries.wrapped.StacktraceListView_CopyAll(); } e.Use(); } }
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(); } }
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(GUIStyle headerStyle, HierarchyFrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.valid || selection.Count == 0) { DrawEmptyPane(headerStyle); return; } InitIfNeeded(); UpdateIfNeeded(frameDataView, selection[0]); var selectedSampleId = m_TreeView.GetSelectedFrameDataViewId(); if (selectedSampleId != -1) { frameDataView.GetItemMergedSampleCallstack(selectedSampleId, m_TreeView.state.selectedIDs[0], m_CachedCallstack); } var showCallstack = m_CachedCallstack.Count > 0; if (showCallstack) { SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea); } // Detailed list var rect = EditorGUILayout.BeginVertical(Styles.expandedArea); m_TreeView.OnGUI(rect); EditorGUILayout.EndVertical(); if (showCallstack) { // Callstack area EditorGUILayout.BeginVertical(Styles.expandedArea); m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll); var sb = new StringBuilder(kCallstackText + '\n'); foreach (var addr in m_CachedCallstack) { var methodInfo = frameDataView.ResolveMethodInfo(addr); if (string.IsNullOrEmpty(methodInfo.methodName)) { sb.AppendFormat("0x{0:X}\n", addr); } else if (string.IsNullOrEmpty(methodInfo.sourceFileName)) { sb.AppendFormat("0x{0:X}\t{1}\n", addr, methodInfo.methodName); } else if (methodInfo.sourceFileLine == 0) { sb.AppendFormat("0x{0:X}\t{1}\t{2}\n", addr, methodInfo.methodName, methodInfo.sourceFileName); } else { sb.AppendFormat("0x{0:X}\t{1}\t{2}:{3}\n", addr, methodInfo.methodName, methodInfo.sourceFileName, methodInfo.sourceFileLine); } } EditorGUILayout.TextArea(sb.ToString(), Styles.callstackTextArea); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); } }
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(); }
public static void BeginHorizontalSplit(SplitterState state, params GUILayoutOption[] options) => SplitterGUILayout.BeginHorizontalSplit(state.state, options);