Ejemplo n.º 1
0
    protected override void OnUpdate()
    {
        foreach (GraphStream graphStream in m_GraphStreams)
        {
            graphStream.CompleteInputDependencies();
            DebuggerTracer.GraphTrace graphTrace = DebuggerTracer.GetGraphData(graphStream.GraphId, createIfAbsent: true);
            var reader = graphStream.AsReader();
            var frame  = Time.frameCount;

            DebuggerTracer.FrameData frameData = null;
            for (int i = 0; i < reader.ForEachCount; i++)
            {
                reader.BeginForEachIndex(i);
                DebuggerTracer.EntityFrameTrace entityData = null;
                while (reader.RemainingItemCount > 0)
                {
                    if (frameData == null)
                    {
                        frameData = graphTrace.GetFrameData(frame, createIfAbsent: true);
                    }

                    var   callFrame = reader.Read <DataType>();
                    ulong nodeId1, nodeId2;
                    switch (callFrame)
                    {
                    case DataType.Entity:
                        var e = ReadEntity(ref reader);
                        entityData = frameData.GetEntityFrameTrace(e.Index, createIfAbsent: true);
                        break;

                    case DataType.Step:
                        Assert.IsTrue(entityData != null);
                        ReadStepRecord(ref reader, out nodeId1, out nodeId2, out var stepOffset, out var progress);
                        entityData.SetLastCallFrame(nodeId1, nodeId2, stepOffset, progress);
                        break;

                    case DataType.Data:
                    {
                        Assert.IsTrue(entityData != null);
                        ReadValueRecord(ref reader, out nodeId1, out nodeId2, out var value);
                        entityData.RecordValue(value, nodeId1, nodeId2);
                        break;
                    }
                    }
                }

                reader.EndForEachIndex();
            }

            graphStream.Dispose();
        }
        m_GraphStreams.Clear();
    }
Ejemplo n.º 2
0
    public static DebuggerTracer.EntityFrameTrace GetRecorder(int graphId, int targetIndex)
    {
        Assert.IsTrue(InternalEditorUtility.CurrentThreadIsMainThread());
        // TODO cache graphdata/frametrace
        var frame = Time.frameCount;

        DebuggerTracer.GraphTrace graphTrace = DebuggerTracer.GetGraphData(graphId, true);
        var frameData = graphTrace.GetFrameData(frame, createIfAbsent: true);

        var entityData = frameData.GetEntityFrameTrace(targetIndex, createIfAbsent: true);

        return(entityData);
    }
        public void OnGUI(Rect timeRect)
        {
            // sync timeline and tracing toolbar state both ways
            m_State.CurrentTime = TimelineState.FrameToTime(m_VSWindowState.currentTracingFrame);

            if (EditorApplication.isPlaying && !EditorApplication.isPaused)
            {
                if (m_State.MaxVisibleTime < m_State.CurrentTime + k_MinTimeVisibleOnTheRight)
                {
                    m_TimeArea.SetShownRange(m_State.CurrentTime + k_MinTimeVisibleOnTheRight - m_State.MaxVisibleTime);
                }
            }

            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;

            // time scales
            GUILayout.BeginArea(timeRect);
            m_TimeArea.Draw(timeRect);
            GUILayout.EndArea();
            GUI.BeginGroup(timeRect);

            DebuggerTracer.GraphTrace trace = DebuggerTracer.GetGraphData((m_VSWindowState?.AssetModel as Object)?.GetInstanceID() ?? -1, false);
            var frameHasDataColor           = new Color32(68, 192, 255, 255);

            if (trace != null && trace.AllFrames.Count > 0)
            {
                float frameDeltaToPixel        = m_TimeArea.FrameDeltaToPixel();
                DebuggerTracer.FrameData first = trace.AllFrames[0];
                DebuggerTracer.FrameData last  = trace.AllFrames[trace.AllFrames.Count - 1];
                float start = m_TimeArea.FrameToPixel(first.Frame);
                float width = frameDeltaToPixel * Mathf.Max(last.Frame - first.Frame, 1);

                EditorGUI.DrawRect(new Rect(start, k_FrameRectangleHeight, width, k_FrameRectangleWidth), frameHasDataColor);
            }

            // playing head
            m_Overlay.OnGUI(timeRect, timeRect);
            GUI.EndGroup();
        }