public TracingTimeline(VseGraphView vseGraphView, State vsWindowState, IMGUIContainer imguiContainer) { m_VseGraphView = vseGraphView; m_VSWindowState = vsWindowState; m_ImguiContainer = imguiContainer; m_TimeArea = new TimeArea(); m_Overlay = new AnimEditorOverlay() { PlayHeadColor = new Color(0.2117647F, 0.6039216F, 0.8F) }; m_State = new TimelineState(m_TimeArea); m_Overlay.state = m_State; var debugger = m_VSWindowState?.CurrentGraphModel?.Stencil?.Debugger; IGraphTrace trace = debugger?.GetGraphTrace(m_VSWindowState?.CurrentGraphModel, m_VSWindowState.CurrentTracingTarget); if (trace?.AllFrames != null && trace.AllFrames.Count > 0) { int firstFrame = trace.AllFrames[0].Frame; int lastFrame = trace.AllFrames[trace.AllFrames.Count - 1].Frame; m_TimeArea.SetShownRange( firstFrame - k_MinTimeVisibleOnTheRight, lastFrame + k_MinTimeVisibleOnTheRight); } }
public TracingTimeline(GraphView graphView, GraphToolState windowGraphToolState) { m_GraphView = graphView; m_WindowGraphToolState = windowGraphToolState; m_TimeArea = new TimeArea(); m_Overlay = new AnimEditorOverlay() { PlayHeadColor = new Color(0.2117647F, 0.6039216F, 0.8F) }; m_State = new TimelineState(m_TimeArea); m_Overlay.state = m_State; var debugger = ((Stencil)m_WindowGraphToolState?.WindowState.GraphModel?.Stencil)?.Debugger; IGraphTrace trace = debugger?.GetGraphTrace(m_WindowGraphToolState?.WindowState.GraphModel, m_WindowGraphToolState.TracingControlState.CurrentTracingTarget); if (trace?.AllFrames != null && trace.AllFrames.Count > 0) { int firstFrame = trace.AllFrames[0].Frame; int lastFrame = trace.AllFrames[trace.AllFrames.Count - 1].Frame; m_TimeArea.SetShownRange( firstFrame - k_MinTimeVisibleOnTheRight, lastFrame + k_MinTimeVisibleOnTheRight); } }
public void OnGUI(Rect timeRect) { // sync timeline and tracing toolbar state both ways m_State.CurrentTime = TimelineState.FrameToTime(m_VSWindowState.CurrentTracingFrame); m_Overlay.HandleEvents(); int timeChangedByTimeline = TimelineState.TimeToFrame(m_State.CurrentTime); // force graph update if (timeChangedByTimeline != m_VSWindowState.CurrentTracingFrame) { m_VSWindowState.CurrentTracingStep = -1; } m_VSWindowState.CurrentTracingFrame = timeChangedByTimeline; GUI.BeginGroup(timeRect); var debugger = m_VSWindowState?.CurrentGraphModel?.Stencil?.Debugger; IGraphTrace trace = debugger?.GetGraphTrace(m_VSWindowState?.CurrentGraphModel, m_VSWindowState.CurrentTracingTarget); if (trace?.AllFrames != null && trace.AllFrames.Count > 0) { float frameDeltaToPixel = m_TimeArea.FrameDeltaToPixel(); int firstFrame = trace.AllFrames[0].Frame; int lastFrame = trace.AllFrames[trace.AllFrames.Count - 1].Frame; float start = m_TimeArea.FrameToPixel(firstFrame); float width = frameDeltaToPixel * Mathf.Max(lastFrame - firstFrame, 1); // draw active range EditorGUI.DrawRect(new Rect(start, timeRect.yMax - k_FrameRectangleHeight, width, k_FrameRectangleHeight), k_FrameHasDataColor); // draw per-node active ranges var framesPerNode = IndexFramesPerNode(ref s_FramesPerNodeCache, m_VSWindowState?.CurrentGraphModel.Stencil, trace, firstFrame, lastFrame, m_VSWindowState.CurrentTracingTarget, out bool invalidated); // while recording in unpaused playmode, adjust the timeline to show all data // same if the cached data changed (eg. Load a trace dump) if (EditorApplication.isPlaying && !EditorApplication.isPaused || invalidated) { m_TimeArea.SetShownRange( firstFrame - k_MinTimeVisibleOnTheRight, lastFrame + k_MinTimeVisibleOnTheRight); } if (framesPerNode != null) { INodeModel nodeModelSelected = m_VseGraphView.selection .OfType <IHasGraphElementModel>() .Select(x => x.GraphElementModel) .OfType <INodeModel>() .FirstOrDefault(); if (nodeModelSelected != null && framesPerNode.TryGetValue(nodeModelSelected.Guid, out List <(int InclusiveFirstFrame, int ExclusiveLastFrame)> frames)) { foreach (var frameInterval in frames) { float xStart = m_TimeArea.FrameToPixel(frameInterval.InclusiveFirstFrame); float xEnd = m_TimeArea.FrameToPixel(frameInterval.ExclusiveLastFrame) - Mathf.Min(1, frameDeltaToPixel * 0.1f); Rect rect = new Rect( xStart, timeRect.yMin, xEnd - xStart, timeRect.yMax); EditorGUI.DrawRect(rect, k_FrameHasNodeColor); } } } } GUI.EndGroup(); // time scales GUILayout.BeginArea(timeRect); m_TimeArea.Draw(timeRect); GUILayout.EndArea(); // playing head m_Overlay.OnGUI(timeRect, timeRect); }