private void DrawCurrentEvent(Rect rect, FrameDebuggerEvent[] descs) { int num = FrameDebuggerUtility.limit - 1; if (num >= 0 && num < descs.Length) { GUILayout.BeginArea(rect); FrameDebuggerEvent frameDebuggerEvent = descs[num]; FrameDebuggerEventData frameDebuggerEventData; bool frameEventData = FrameDebuggerUtility.GetFrameEventData(num, out frameDebuggerEventData); if (frameEventData) { this.DrawRenderTargetControls(frameDebuggerEventData); } GUILayout.Label(string.Format("Event #{0}: {1}", num + 1, FrameDebuggerWindow.s_FrameEventTypeNames[(int)frameDebuggerEvent.type]), EditorStyles.boldLabel, new GUILayoutOption[0]); if (FrameDebuggerUtility.IsRemoteEnabled() && FrameDebuggerUtility.receivingRemoteFrameEventData) { GUILayout.Label("Receiving frame event data...", new GUILayoutOption[0]); } else if (frameEventData) { if (frameDebuggerEventData.vertexCount > 0 || frameDebuggerEventData.indexCount > 0) { this.DrawEventDrawCallInfo(frameDebuggerEventData); } else if (frameDebuggerEvent.type == FrameEventType.ComputeDispatch) { this.DrawEventComputeDispatchInfo(frameDebuggerEventData); } } GUILayout.EndArea(); } }
private void ClickEnableFrameDebugger() { bool flag = FrameDebuggerUtility.IsLocalEnabled() || FrameDebuggerUtility.IsRemoteEnabled(); bool flag2 = !flag && this.m_AttachProfilerUI.IsEditor(); if (!flag2 || FrameDebuggerUtility.locallySupported) { if (flag2) { if (EditorApplication.isPlaying && !EditorApplication.isPaused) { EditorApplication.isPaused = true; } } if (!flag) { FrameDebuggerUtility.SetEnabled(true, ProfilerDriver.connectedProfiler); } else { FrameDebuggerUtility.SetEnabled(false, FrameDebuggerUtility.GetRemotePlayerGUID()); } if (FrameDebuggerUtility.IsLocalEnabled()) { GameView gameView = (GameView)WindowLayout.FindEditorWindowOfType(typeof(GameView)); if (gameView) { gameView.ShowTab(); } } this.m_PrevEventsLimit = FrameDebuggerUtility.limit; this.m_PrevEventsCount = FrameDebuggerUtility.count; } }
private bool DrawToolbar(FrameDebuggerEvent[] descs) { bool flag1 = false; bool flag2 = !this.m_AttachProfilerUI.IsEditor() || FrameDebuggerUtility.locallySupported; GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); EditorGUI.BeginDisabledGroup(!flag2); GUILayout.Toggle((FrameDebuggerUtility.IsLocalEnabled() ? 1 : (FrameDebuggerUtility.IsRemoteEnabled() ? 1 : 0)) != 0, FrameDebuggerWindow.styles.recordButton, EditorStyles.toolbarButton, new GUILayoutOption[1] { GUILayout.MinWidth(80f) }); EditorGUI.EndDisabledGroup(); if (EditorGUI.EndChangeCheck()) { this.ClickEnableFrameDebugger(); flag1 = true; } this.m_AttachProfilerUI.OnGUILayout((EditorWindow)this); bool flag3 = FrameDebuggerUtility.IsLocalEnabled() || FrameDebuggerUtility.IsRemoteEnabled(); if (flag3 && ProfilerDriver.connectedProfiler != FrameDebuggerUtility.GetRemotePlayerGUID()) { FrameDebuggerUtility.SetEnabled(false, FrameDebuggerUtility.GetRemotePlayerGUID()); FrameDebuggerUtility.SetEnabled(true, ProfilerDriver.connectedProfiler); } GUI.enabled = flag3; EditorGUI.BeginChangeCheck(); EditorGUI.BeginDisabledGroup(FrameDebuggerUtility.count <= 1); int newLimit = EditorGUILayout.IntSlider(FrameDebuggerUtility.limit, 1, FrameDebuggerUtility.count); EditorGUI.EndDisabledGroup(); if (EditorGUI.EndChangeCheck()) { this.ChangeFrameEventLimit(newLimit); } GUILayout.Label(" of " + (object)FrameDebuggerUtility.count, EditorStyles.miniLabel, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(newLimit <= 1); if (GUILayout.Button(FrameDebuggerWindow.styles.prevFrame, EditorStyles.toolbarButton, new GUILayoutOption[0])) { this.ChangeFrameEventLimit(newLimit - 1); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(newLimit >= FrameDebuggerUtility.count); if (GUILayout.Button(FrameDebuggerWindow.styles.nextFrame, EditorStyles.toolbarButton, new GUILayoutOption[0])) { this.ChangeFrameEventLimit(newLimit + 1); } if (this.m_PrevEventsLimit == this.m_PrevEventsCount && FrameDebuggerUtility.count != this.m_PrevEventsCount && FrameDebuggerUtility.limit == this.m_PrevEventsLimit) { this.ChangeFrameEventLimit(FrameDebuggerUtility.count); } this.m_PrevEventsLimit = FrameDebuggerUtility.limit; this.m_PrevEventsCount = FrameDebuggerUtility.count; EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); return(flag1); }
public void EnableIfNeeded() { if (!FrameDebuggerUtility.IsLocalEnabled() && !FrameDebuggerUtility.IsRemoteEnabled()) { this.m_RTChannel = 0; this.m_RTIndex = 0; this.m_RTBlackLevel = 0f; this.m_RTWhiteLevel = 1f; this.ClickEnableFrameDebugger(); this.RepaintOnLimitChange(); } }
internal void OnGUI() { FrameDebuggerEvent[] frameEvents = FrameDebuggerUtility.GetFrameEvents(); if (this.m_TreeViewState == null) { this.m_TreeViewState = new TreeViewState(); } if (this.m_Tree == null) { this.m_Tree = new FrameDebuggerTreeView(frameEvents, this.m_TreeViewState, this, default(Rect)); this.m_FrameEventsHash = FrameDebuggerUtility.eventsHash; this.m_Tree.m_DataSource.SetExpandedWithChildren(this.m_Tree.m_DataSource.root, true); } if (FrameDebuggerUtility.eventsHash != this.m_FrameEventsHash) { this.m_Tree.m_DataSource.SetEvents(frameEvents); this.m_FrameEventsHash = FrameDebuggerUtility.eventsHash; } int limit = FrameDebuggerUtility.limit; bool flag = this.DrawToolbar(frameEvents); if (!FrameDebuggerUtility.IsLocalEnabled() && !FrameDebuggerUtility.IsRemoteEnabled() && this.m_AttachProfilerUI.IsEditor()) { GUI.enabled = true; if (!FrameDebuggerUtility.locallySupported) { EditorGUILayout.HelpBox("Frame Debugger requires multi-threaded renderer. Usually Unity uses that; if it does not, try starting with -force-gfx-mt command line argument.", MessageType.Warning, true); } EditorGUILayout.HelpBox("Frame Debugger lets you step through draw calls and see how exactly frame is rendered. Click Enable!", MessageType.Info, true); } else { float fixedHeight = EditorStyles.toolbar.fixedHeight; Rect dragRect = new Rect(this.m_ListWidth, fixedHeight, 5f, base.position.height - fixedHeight); dragRect = EditorGUIUtility.HandleHorizontalSplitter(dragRect, base.position.width, 200f, 200f); this.m_ListWidth = dragRect.x; Rect rect = new Rect(0f, fixedHeight, this.m_ListWidth, base.position.height - fixedHeight); Rect rect2 = new Rect(this.m_ListWidth + 4f, fixedHeight + 4f, base.position.width - this.m_ListWidth - 8f, base.position.height - fixedHeight - 8f); this.DrawEventsTree(rect); EditorGUIUtility.DrawHorizontalSplitter(dragRect); this.DrawCurrentEvent(rect2, frameEvents); } if (flag || limit != FrameDebuggerUtility.limit) { this.RepaintOnLimitChange(); } if (this.m_RepaintFrames > 0) { this.m_Tree.SelectFrameEventIndex(FrameDebuggerUtility.limit); this.RepaintAllNeededThings(); this.m_RepaintFrames--; } }
private bool DrawToolbar(FrameDebuggerEvent[] descs) { bool result = false; bool flag = !this.m_AttachProfilerUI.IsEditor() || FrameDebuggerUtility.locallySupported; GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); using (new EditorGUI.DisabledScope(!flag)) { GUILayout.Toggle(FrameDebuggerUtility.IsLocalEnabled() || FrameDebuggerUtility.IsRemoteEnabled(), FrameDebuggerWindow.styles.recordButton, EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.MinWidth(80f) }); } if (EditorGUI.EndChangeCheck()) { this.ClickEnableFrameDebugger(); result = true; } this.m_AttachProfilerUI.OnGUILayout(this); bool flag2 = FrameDebuggerUtility.IsLocalEnabled() || FrameDebuggerUtility.IsRemoteEnabled(); if (flag2 && ProfilerDriver.connectedProfiler != FrameDebuggerUtility.GetRemotePlayerGUID()) { FrameDebuggerUtility.SetEnabled(false, FrameDebuggerUtility.GetRemotePlayerGUID()); FrameDebuggerUtility.SetEnabled(true, ProfilerDriver.connectedProfiler); } GUI.enabled = flag2; EditorGUI.BeginChangeCheck(); int num; using (new EditorGUI.DisabledScope(FrameDebuggerUtility.count <= 1)) { num = EditorGUILayout.IntSlider(FrameDebuggerUtility.limit, 1, FrameDebuggerUtility.count, new GUILayoutOption[0]); } if (EditorGUI.EndChangeCheck()) { this.ChangeFrameEventLimit(num); } GUILayout.Label(" of " + FrameDebuggerUtility.count, EditorStyles.miniLabel, new GUILayoutOption[0]); using (new EditorGUI.DisabledScope(num <= 1)) { if (GUILayout.Button(FrameDebuggerWindow.styles.prevFrame, EditorStyles.toolbarButton, new GUILayoutOption[0])) { this.ChangeFrameEventLimit(num - 1); } } using (new EditorGUI.DisabledScope(num >= FrameDebuggerUtility.count)) { if (GUILayout.Button(FrameDebuggerWindow.styles.nextFrame, EditorStyles.toolbarButton, new GUILayoutOption[0])) { this.ChangeFrameEventLimit(num + 1); } if (this.m_PrevEventsLimit == this.m_PrevEventsCount) { if (FrameDebuggerUtility.count != this.m_PrevEventsCount && FrameDebuggerUtility.limit == this.m_PrevEventsLimit) { this.ChangeFrameEventLimit(FrameDebuggerUtility.count); } } this.m_PrevEventsLimit = FrameDebuggerUtility.limit; this.m_PrevEventsCount = FrameDebuggerUtility.count; } GUILayout.EndHorizontal(); return(result); }
private void DrawCurrentEvent(Rect rect, FrameDebuggerEvent[] descs) { int index = FrameDebuggerUtility.limit - 1; if (index < 0 || index >= descs.Length) { return; } GUILayout.BeginArea(rect); FrameDebuggerEvent desc = descs[index]; FrameDebuggerEventData frameDebuggerEventData; bool frameEventData = FrameDebuggerUtility.GetFrameEventData(index, out frameDebuggerEventData); if (frameEventData) { this.DrawRenderTargetControls(frameDebuggerEventData); } GUILayout.Label(string.Format("Event #{0}: {1}", (object)(index + 1), (object)FrameDebuggerWindow.s_FrameEventTypeNames[(int)desc.type]), EditorStyles.boldLabel, new GUILayoutOption[0]); if (FrameDebuggerUtility.IsRemoteEnabled() && FrameDebuggerUtility.receivingRemoteFrameEventData) { GUILayout.Label("Receiving frame event data..."); } else if (frameEventData && (frameDebuggerEventData.vertexCount > 0 || frameDebuggerEventData.indexCount > 0)) { Shader shader = frameDebuggerEventData.shader; int shaderPassIndex = frameDebuggerEventData.shaderPassIndex; GUILayout.BeginHorizontal(); if (GUILayout.Button("Shader: " + frameDebuggerEventData.shaderName + " pass #" + (object)shaderPassIndex, GUI.skin.label, new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { EditorGUIUtility.PingObject((UnityEngine.Object)shader); Event.current.Use(); } GUILayout.Label(frameDebuggerEventData.shaderKeywords, EditorStyles.miniLabel, new GUILayoutOption[0]); GUILayout.EndHorizontal(); this.DrawStates(frameDebuggerEventData); GUILayout.Space(15f); this.m_AdditionalInfo = (ShowAdditionalInfo)GUILayout.Toolbar((int)this.m_AdditionalInfo, this.m_AdditionalInfoGuiContents); switch (this.m_AdditionalInfo) { case ShowAdditionalInfo.Preview: if (frameEventData && !this.DrawEventMesh(frameDebuggerEventData)) { GUILayout.Label("Vertices: " + (object)frameDebuggerEventData.vertexCount); GUILayout.Label("Indices: " + (object)frameDebuggerEventData.indexCount); break; } break; case ShowAdditionalInfo.ShaderProperties: if (frameEventData) { this.DrawShaderProperties(frameDebuggerEventData.shaderProperties); break; } break; } } GUILayout.EndArea(); }
private void DrawCurrentEvent(Rect rect, FrameDebuggerEvent[] descs) { int num = FrameDebuggerUtility.limit - 1; if (num < 0 || num >= descs.Length) { return; } GUILayout.BeginArea(rect); FrameDebuggerEvent frameDebuggerEvent = descs[num]; FrameDebuggerEventData frameDebuggerEventData; bool frameEventData = FrameDebuggerUtility.GetFrameEventData(num, out frameDebuggerEventData); if (frameEventData) { this.DrawRenderTargetControls(frameDebuggerEventData); } GUILayout.Label(string.Format("Event #{0}: {1}", num + 1, FrameDebuggerWindow.s_FrameEventTypeNames[(int)frameDebuggerEvent.type]), EditorStyles.boldLabel, new GUILayoutOption[0]); if (FrameDebuggerUtility.IsRemoteEnabled() && FrameDebuggerUtility.receivingRemoteFrameEventData) { GUILayout.Label("Receiving frame event data...", new GUILayoutOption[0]); } else if (frameEventData && (frameDebuggerEventData.vertexCount > 0 || frameDebuggerEventData.indexCount > 0)) { Shader shader = frameDebuggerEventData.shader; int shaderPassIndex = frameDebuggerEventData.shaderPassIndex; GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button(string.Concat(new object[] { "Shader: ", frameDebuggerEventData.shaderName, " pass #", shaderPassIndex }), GUI.skin.label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { EditorGUIUtility.PingObject(shader); Event.current.Use(); } GUILayout.Label(frameDebuggerEventData.shaderKeywords, EditorStyles.miniLabel, new GUILayoutOption[0]); GUILayout.EndHorizontal(); this.DrawStates(frameDebuggerEventData); GUILayout.Space(15f); this.m_AdditionalInfo = (ShowAdditionalInfo)GUILayout.Toolbar((int)this.m_AdditionalInfo, this.m_AdditionalInfoGuiContents, new GUILayoutOption[0]); ShowAdditionalInfo additionalInfo = this.m_AdditionalInfo; if (additionalInfo != ShowAdditionalInfo.Preview) { if (additionalInfo == ShowAdditionalInfo.ShaderProperties) { if (frameEventData) { this.DrawShaderProperties(frameDebuggerEventData.shaderProperties); } } } else if (frameEventData) { if (!this.DrawEventMesh(frameDebuggerEventData)) { GUILayout.Label("Vertices: " + frameDebuggerEventData.vertexCount, new GUILayoutOption[0]); GUILayout.Label("Indices: " + frameDebuggerEventData.indexCount, new GUILayoutOption[0]); } } } GUILayout.EndArea(); }